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 _12._4作业
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//*****
//*****
//*****
//*****
//*****
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 5; i++)
{
for (int j = 0; j <= 5; j++)
{
textBox1.Text += "*";
}
textBox1.Text += "\r\n";
}
}
// *
// **
// ***
// ****
// *****
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j <= i; j++)
{
textBox2.Text += "*";
}
textBox2.Text += "\r\n";
}
}
// *
// **
// ***
// ****
//*****
private void button3_Click(object sender, EventArgs e)
{
for(int i = 0; i < 5; i++)
{
for (int k = 0; k < 5 - i - 1; k++)
{
textBox3.Text += " ";
}
for (int j = 0; j <= i; j++)
{
textBox3.Text += "*";
}
textBox3.Text += "\r\n";
}
}
//*****
//****
//***
//**
//*
private void button4_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5 - i; j++)
{
textBox4.Text += "*";
}
textBox4.Text += "\r\n";
}
}
/******
****
***
**
*
*/ private void button5_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int k = 0; k < i; k++)
{
textBox5.Text += " ";
}
for (int j = 0; j < 5 - i; j++)
{
textBox5.Text += "*";
}
textBox5.Text += "\r\n";
}
}
//梯形
private void button6_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < i; j++)
{
textBox6.Text += " ";
}
for (int a = 0; a < 5; a++)
{
textBox6.Text += "*";
}
textBox6.Text += "\r\n";
}
}
//等腰三角形
private void button7_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 5; i++)
{
for (int j = 0; j < 5 - i; j++)
{
textBox7.Text += " ";
}
for (int a = 0; a < i * 2 - 1; a++)
{
textBox7.Text += "*";
}
textBox7.Text += "\r\n";
}
}
//空心梯形
private void button8_Click(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < i; j++)
{
textBox8.Text += " ";
}
for (int a = 0; a < 5; a++)
{
if (i == 0 || i == 4)
{
textBox8.Text += "*";
}
else
{
textBox8.Text += ((a == 0 || a == 4) ? "*" : " ");
}
}
textBox8.Text += "\r\n";
}
}
//菱形
private void button9_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 9; i++)
{
if (i < 5)
{
for (int j = 0; j < 5 - i - 1; j++)
{
textBox9.Text += "";
}
for (int a = 0; a < i * 2 + 1; a++)
{
textBox9.Text += "*";
}
}
else
{
for (int s = 0; s < i - 4; s++)
{
textBox9.Text += " ";
}
for (int b = 0; b < (9 - i) * 2 - 1; b++)
{
textBox9.Text += "*";
}
textBox9.Text += "\r\n";
}
}
}
//乘法表
private void button10_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j <=i; j++)
{
textBox10.Text += (j+"*"+i+"="+i*j+"\t");
}
textBox10.Text+="\r\n";
}
}
}
}
for循环练习
最新推荐文章于 2021-10-10 08:52:50 发布