网站开发编程,网站维护的协议,网站备案查询工信部官网,自学平面设计入门教程百文买鸡题目#xff1a; ⽤100⽂买⼀百只鸡#xff0c;其中公鸡#xff0c;⺟鸡#xff0c;⼩鸡#xff0c;都必须要有#xff0c;公鸡3⽂⼀只#xff0c;⺟鸡5⽂⼀只#xff0c;⼩鸡2⽂⼀只#xff0c;请问公鸡、⺟鸡、⼩鸡要买多少只刚好凑⾜100⽂。
// x y z 公鸡…百文买鸡题目 ⽤100⽂买⼀百只鸡其中公鸡⺟鸡⼩鸡都必须要有公鸡3⽂⼀只⺟鸡5⽂⼀只⼩鸡2⽂⼀只请问公鸡、⺟鸡、⼩鸡要买多少只刚好凑⾜100⽂。
// x y z 公鸡、⺟鸡、⼩鸡
int count 0;
for (int x 1; x 100 / 3; x) // 公鸡
{for (int y 1; y 100 / 5; y) // ⺟鸡{for (int z 1; z 100 / 2; z) // 小鸡{if (3 * x 5 * y z * 2 100) // 条件{count;Console.WriteLine(公鸡{0}只,母鸡{1}只,小鸡{2}只, x, y, z);}}}
}
Console.WriteLine(count 种方法); 水仙花数题目 打印出所有的“⽔仙花数”所谓“⽔仙花数”是指⼀个三位数其各位数字⽴⽅等于该数本⾝。例如153 1 * 1 * 1 5 * 5 * 5 3 * 3 * 3所以153是“⽔仙花数”。
int n Convert.ToInt32(Console.ReadLine());
for (int i 100; i n 1; i)
{int a i / 100;// 百int b i / 10 % 10;// 十 int c i % 10;// 个if (a * a * a b * b * b c * c * c i){Console.WriteLine({0}是水仙花数。, i);}
}