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_X_Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int num, n;
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
num = int.Parse(textBox2.Text);
}
private void button1_Click(object sender, EventArgs e)
{
n = num;
for (int r = 1; r <= num; r++, n--)
{
for (int c = n; c <= num; c++)
{
textBox1.Text += (c.ToString());
}
for (int c = r, j = num + 1; c > 1; c--, j++)
{
textBox1.Text += (j.ToString());
}
textBox1.Text += "\r\n";
}
for (int r = 2; r <= num; r++)
{
for (int c = r; c <= num; c++)
{
textBox1.Text += (c.ToString());
}
for (int c = num - r, j = num + 1; c >= 1; c--, j++)
{
textBox1.Text += (j.ToString());
}
textBox1.Text += "\r\n";
}
}
}
}
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.