Asteriscos - VIII




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

        int n;
        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            n = int.Parse(textBox2.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            for (int r = 1; r <= 10; r++, n--)
            {
                for (int c = 1; c <= n; c++)
                {
                    textBox1.Text += " C";
                }
                for (int c = 1; c <= r; c++)
                {
                    if (c == 1)
                    {
                        textBox1.Text += " *";
                    }
                    else
                    {
                        textBox1.Text += " C";
                    }
                }



                for (int c = r; c > 1; c--)
                {
                    if (c == 2)
                    {
                        textBox1.Text += " *";
                    }
                    else
                    {
                        textBox1.Text += " C";
                    }
                }
                for (int c = n; c >= 1; c--)
                {
                    textBox1.Text += " C";
                }
                textBox1.Text += "\r\n";
            }
        }
    }
}

No hay comentarios:

Publicar un comentario

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