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_XIV_Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
int num, z = 1, p, n;
private void button1_Click(object sender, EventArgs e)
{
for (int r = 1; r <= num; r++, z = z + 2)
{
for (int c = 1; c <= z; c++)
{
if (c % 2 == 0)
{
textBox1.Text += "*";
}
else
{
textBox1.Text += (r.ToString());
}
}
textBox1.Text += "\r\n";
}
n = num + 3;
p = num - 1;
for (int r = num; r >= 1; r--, n = n - 2, p--)
{
for (int c = 1; c <= n; c++)
{
if (c % 2 == 0)
{
textBox1.Text += "*";
}
else
{
textBox1.Text += (p.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.