for循环
for(int=0(定义变量);i<length(条件表达式);i++(状态改变)){(循环体)}
/* Console.WriteLine("输入:");
int a = int.Parse(Console .ReadLine ());
int b = 0;
for (int i =1;i<=a ; i++)
{
if (a % i == 0) { b++; }
}
if (b == 2)
{ Console.WriteLine("这是一个质数"); }
else { Console.WriteLine("这不是一个质数"); }*/
/* int c = 0;
for (int i = 0; i <= 100; i++)
{
int b = 0;
for (int e = 1; e <= i; e++)
{
if (i % e == 0) { b++; }
}
if (b == 2)
{
c = c + i;
}
}
Console.WriteLine(c);*/
//打印4个直角三角形,打印菱形
/* for (int i = 1; i <= 10; i++) //行
{
for (int j = 1; j <= i; j++)//列
{
Console.Write("☆");
}
Console.WriteLine(" ");
}
for (int t = 10; t >= 1; t--)
{
for (int j = 1; j <= t; j++)
{
Console.Write("☆");
}
Console.WriteLine(" ");
}*/
// 输入一个数n,求n的阶乘
/* Console.WriteLine("输入:");
int n = int.Parse(Console .ReadLine ());
int b = 1;
for (int i = 1; i <= n; i++)
{
b = b * i;
}
Console.WriteLine(b);*/
//输入一个数n,求1-n的阶乘和
/* Console.WriteLine("输入:");
int n = int.Parse(Console .ReadLine ());
int a = 0;
for (int m = 1; m <=n; m++)
{
int b = 1;
for (int i = 1; i <= m; i++)
{
b = b * i;
} a = a + b;
}
Console.WriteLine(a);*/
/* Console.WriteLine("输入:");
int n = int.Parse(Console.ReadLine());
int b = 1;
int a = 0;
for (int i = 1; i <= n; i++)
{
b = b * i;
a = a + b;
}
Console.WriteLine(b);
Console.WriteLine(a);*/
穷举 //牙膏5元,牙刷2元,肥皂3元,100元全部花光,有几种可能
/* int k = 0;
for (int g = 1; 5*g <= 100; g++)
{
for (int s = 1; 2*s <= 100; s++)
{
for (int f = 1; 3*f<=100; f++)
{
if (5 * g + 2 * s + 3 * f == 100)
{ Console.WriteLine(g + "牙膏" + s + "牙刷" + f + "肥皂"); k++; }
}
}
}
Console.WriteLine(k);*/
// 一对幼兔一个月成长成小兔,再过一个月长成成兔并生下幼兔,
//问24个月后一共有多少对兔子,一对成兔每月生下一对幼兔。
/* Console.WriteLine("月份:");
int m = int.Parse(Console.ReadLine());
int yt = 1;
int xt = 0;
int ct = 0;
int zt = 1;
for (int i = 1; i <= m; i++)
{
if (i == 1) { ct = 0; yt = 1; xt = 0; }
else
{
ct = ct + xt;
xt = yt;
yt = ct;
}
}
zt = ct + yt + xt;
Console.WriteLine(xt + "小兔" + yt + "幼兔" + ct + "成兔");
Console.WriteLine(zt);*/
//输入十个人的分数,求最高分
/* Console.Write("输入人数:");
int n = int.Parse(Console .ReadLine ());
int[] arr = new int[n];
int g = 0;
for (int i = 0; i < n; i++)
{
Console.Write("第"+(i+1)+"个人的成绩为:");
arr[i] = int.Parse(Console .ReadLine ());
if (g < arr[i]) { g = arr[i]; }
}
Console.WriteLine("最高分是:"+g);*/
//输入是个人的分数,去掉最高最低分,求平均分
冒泡排序
/* Console.Write("输入人数:");
int n = int.Parse(Console.ReadLine());
int[] arr = new int[n];
int g = 0;
int d = 999;
int s = 0;
for (int i = 0; i < n; i++)
{
Console.Write("第" + (i + 1) + "个人的成绩为:");
arr[i] = int.Parse(Console.ReadLine());
if (g < arr[i]) { g = arr[i]; }
if (d > arr[i]) { d = arr[i]; }
s += arr[i];
}
double a = (s - g - d) / (n - 2);
Console.WriteLine("最高分是:" + g);
Console.WriteLine("最低分是:" + d);
Console.WriteLine("平均分是:" + a);
*/