Figura - XV



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_XVI_Forms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        char r, c, ch, h;

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            ch = Convert.ToChar(textBox2.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            if (ch >= 'a' && ch <= 'z')
            {
                ch = (char)(ch - 32);
            }
            h = ch;
            for (r = 'A'; r <= ch; r++, h--)
            {
                for (c = 'A'; c <= h; c++)
                {
                    textBox1.Text += (c.ToString());
                }
                for (c = (char)(h - 1); c >= 'A'; c--)
                {
                    textBox1.Text += (c.ToString());
                }
                textBox1.Text += "\r\n";
            }
        }
    }
}

No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.