c#题目
给你100块钱,买100只鸡,公鸡5块一只,母鸡3块一鸡,小鸡3只一元。问有几种方案。谁会写这个代码?帮帮忙!
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int xiaojimax = 100; int gongjimax = 20; int mujimax = 33; int sum = 0; for(int i=0;i<=xiaojimax;i++) for(int j=0;j<=gongjimax;j++) for (int k = 0; k <= mujimax; k++) { if (i + j + k == 100 && (i / 3 + 3 * k + 5 * j) <= 100) { sum++; } } Console.WriteLine(sum); Console.ReadKey(); } } }