using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Triangulo_XV_Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int num;
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
for (int r = 1; r <= num; r++)
{
for (int sp = num - r; sp >= 1; sp--)
{
textBox1.Text += " ";
}
textBox1.Text += (r.ToString());
for (int sp = r * 2; sp > 1; sp--)
{
textBox1.Text += " ";
}
textBox1.Text += (r.ToString());
textBox1.Text += "\r\n";
}
for (int r = 1, n = num - 1; r < num; r++, n--)
{
for (int sp = r; sp >= 1; sp--)
{
textBox1.Text += " ";
}
textBox1.Text += (n.ToString());
for (int sp = n * 2; sp > 1; sp--)
{
textBox1.Text += " ";
}
textBox1.Text += (n.ToString());
textBox1.Text += "\r\n";
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
num = int.Parse(textBox2.Text);
}
}
}
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.