标签:
1.质数
int b = 0;
for (int i = 1; i <= 100;i++ )
{
int a = 0;
for (int l = 1; l <= i;l++ )
{
if(i%l==0)
{
a++;
}
}
if(a==2)
{
b += i;
Console.Write(i+"\t");
}
}
Console.Write("总和是:"+b);
2.三个数由大到小排序
Console.Write("请输入第一个数字:");
int a = int.Parse(Console.ReadLine());
Console.Write("请输入第二个数字:");
int b = int.Parse(Console.ReadLine());
Console.Write("请输入第三个数字:");
int c = int.Parse(Console.ReadLine());
if(a>b)
{
int x = b;
b = a;
a = x;
}
if(b>c)
{
int x = c;
c = b;
b = x;
if (a > b)
{
int y= b;
b = a;
a = y;
}
}
Console.Write(c);
Console.Write(b);
Console.Write(a);
标签:
原文地址:http://www.cnblogs.com/mazhijie/p/5456554.html