这是一个送给初学 c#的程序,简单明了,用于计算平均数,请自己研究一下它的结构。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace Test { class Program { static void Main(string[] args) { do { Console.ResetColor(); Console.WriteLine("rn欢迎使用本程序。请输入一系列数。rn"); //开始记录数字 int s = 0; double z = 0; do { Console.Write("数字(按回车确认,直接按回车结束):_"); string i = Console.ReadLine(); int n; if (int.TryParse(i, out n)) { s++; z += n; } else { break; } } while (true); if (s == 0) { Console.WriteLine("-> 参数错误。"); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("-> 平均数:{0}。感谢您的使用。", (double)(z / s)); } } while (true); } } } |
...
@刹那:啊?您是什么意思?
я так считаю: бесподобно. а82ч
Very nice I'm sure abou it vidps2datxw