标签:ted str span ram 输入 停止 div ring stat
namespace _08.练习01{class Program{static void Main(string[] args){//练习1:循环录入5个人的年龄并计算平均年龄,如果录入的数据出现负数或大于100,//立即停止输入并报错int avg = 0; //用来保存平均成绩.int score = 0; //用来保存每一次输入的成绩bool b = true; //用来反馈错误for (int i = 1; i <=5; i++){Console.WriteLine("请输入第{0}个人的年龄:",i);b=int.TryParse(Console.ReadLine(),out score);if (b == false){Console.WriteLine("你输入的不是年龄");break;}else if(score>100||score<0){Console.WriteLine("你的出入超出范围!");break;}}Console.ReadKey();}}}
标签:ted str span ram 输入 停止 div ring stat
原文地址:http://www.cnblogs.com/HelloZyjS/p/6018828.html