//羽毛球拍15元,球3元,水2元.200元每种至少一个,有多少可能 int m = 0; for (int x = 1; x * 15 <= 200; x++) { for (int y = 0; y * 3 <= 200; y++) { for (int z = 0; z * 2 <= 200; z++) { if (15 * x + 3 * y + 2 * z == 200) { Console.WriteLine(x+"副拍子"+y +"个球"+z +"瓶水"); m++; } } } } Console.Write("一共有多少可能性" + m);
//一张纸0.00007m折多少次跟珠峰一样高 decimal hou= 0.00007M; for (int i = 1; i > 0; i++) { hou = hou * 2; if (hou > 8848) { Console.WriteLine(i); break;//终止循环,跳出循环 } }
//100以内的质数的和 int sum=0; for (int k = 1; k <= 100; k++) { int count = 0; for (int i = 1; i <= k; i++) { if (k % i == 0) { count++; } } if(count==2) { sum+=k; } } Console.WriteLine(sum);