码迷,mamicode.com
首页 > 其他好文 > 详细

第六天

时间:2016-05-03 22:21:15      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

1.十八个年龄

Console.Write("请输入您的名字:");
string a = Console.ReadLine();
for (int i = 1; i <= 18;i++ )
{
Console.Write("我叫"+a+","+"我今年"+i+"岁了。");
switch (i)
{
case 6: Console.Write("我上小学了!"); break;
case 11: Console.Write("我上初中了!"); break;
case 15: Console.Write("我上高中了!"); break;
case 18: Console.Write("我成年了!考上了北大!"); break;
}
Console.WriteLine();
}
Console.ReadLine();

2.99乘法表

for (int i = 1; i <= 9; i++)
{
for (int l = 1; l <= i; l++)
{
int a = l * i;
Console.Write(l + "*" + i + "=" + a + "\t");
}
Console.WriteLine();
}

3.各种三角形

//三角形1
for (int i = 1; i <= 5; i++)
{
for (int l = 1; l <= i; l++)
{
Console.Write("★");
}
Console.WriteLine();
}
//三角形2
for (int i = 1; i <= 5; i++)
{
for (int l = i; l <= 5; l++)
{
Console.Write("★");
}
Console.WriteLine();
}
//三角形3
for (int i = 1; i <= 5; i++)
{
for (int l = i; l < 5; l++)
{
Console.Write(" ");
}
for (int l = 1; l <= i; l++)
{
Console.Write("★");
}
Console.WriteLine();
}
//三角形4
for (int i = 1; i <= 5; i++)
{
for (int l = 1; l < i; l++)
{
Console.Write(" ");
}
for (int l = i; l <= 5; l++)
{
Console.Write("★");
}
Console.WriteLine();
}
//三角形5
for (int i = 1; i <= 5; i++)
{
for (int l = i; l < 5; l++)
{
Console.Write(" ");
}
for (int l = 1; l <= i; l++)
{
Console.Write("★");
}
Console.WriteLine();
}

 4.菱形

Console.Write("请输入一个数字");
int a = int.Parse(Console.ReadLine());
for (int i = 1; i <= a; i++)
{
for (int l = i; l < a; l++)
{
Console.Write(" ");
}
for (int l = 1; l <= i; l++)
{
Console.Write("★");
}
Console.WriteLine();
}
for (int i = 1; i <= a; i++)
{
for (int l = 0; l < i; l++)
{
Console.Write(" ");
}
for (int l = i; l <= (a - 1); l++)
{
Console.Write("★");
}
Console.WriteLine();
}

 

第六天

标签:

原文地址:http://www.cnblogs.com/mazhijie/p/5456547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!