标签:os for 2014 问题 amp line new c++
//求5!+ 4!+3! +2! +1!
long A = 0;
for (int i = 1; i <= 1000; i++)
{
long z = 1; int j = i; while (j > 0)
{
z *= j; j--;
}
A += z;
}
Console.Write("结果:" + A + System.Environment.NewLine);
//求100以内的素数
int i = 1;
bool s;
for (; i < 100; i++)
{
s = true;
for (int j = 2; j < i; j++)
{
if (i % j == 0)
s = false;
}
if (s)
Console.WriteLine(i.ToString());
//执行任务问题
for (int A = 0; A <= 1; A++)
for (int B = 0; B <= 1; B++)
for (int C = 0; C <= 1; C++)
for (int D = 0; D <= 1; D++)
for (int E = 0; E <= 1; E++)
for (int F = 0; F <= 1;F++ )
{
if (A + B > 0 && A + D <= 1 && A + E + F == 2 && B + C >= 1 && C + D == 1)
if (D == 0 && E + D == 0)
{
Console.WriteLine("A="+A+" B="+B+" C="+C+" D="+D+" E="+E+" F="+F+"");
}
else if (D ==1&&D+E>=1)
{
Console.WriteLine("A="+A+" B="+B+" C="+C+" D="+D+" E="+E+" F="+F+"");
}
}
//百鸡百钱 x = 公鸡 y = 母鸡 z =小鸡
for (int x = 1; x < 50; x++)
for (int y = 1; y < 100; y++)
for (int z = 2; z < 100; z++)
{
if (x * 2 + y * 1 + z * 0.5 == 100 && x + y + z == 100)
{
Console.WriteLine("公鸡"+x+"只,母鸡"+y+"只,小鸡"+z+"只");
}
}
标签:os for 2014 问题 amp line new c++
原文地址:http://www.cnblogs.com/jackjms/p/3922320.html