标签:threading ace ram day span 输出 reading -- 练习
练习2
对于学员成绩的评测 成绩>=90:A 成绩>=80&&成绩<90:B 成绩>=70&&成绩<80:C 成绩>=60&&成绩<70:D 成绩<60:E
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace 草稿 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 Console.WriteLine("请输入一个考试成绩"); 14 int score = Convert.ToInt32(Console.ReadLine()); 15 16 switch (score/10) 17 { 18 case 10: 19 case 9: Console.WriteLine("A"); 20 break; 21 case 8: Console.WriteLine("B"); 22 break; 23 case 7: 24 Console.WriteLine("C"); 25 break; 26 case 6: 27 Console.WriteLine("D"); 28 break; 29 default: Console.WriteLine("E"); 30 break; 31 } 32 Console.ReadKey(); 33 } 34 } 35 }
练习3
判断闰年:用户输入年份,输出该月的天数(2月份的判断是重点)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace 草稿 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 Console.WriteLine("请输入一个年份"); 14 try 15 { 16 int year = Convert.ToInt32(Console.ReadLine()); 17 Console.WriteLine("请输入一个月份"); 18 try 19 { 20 int month = Convert.ToInt32(Console.ReadLine()); 21 int day = 0; //声明一个变量存储天数 22 23 switch (month) 24 { 25 case 1: 26 case 3: 27 case 5: 28 case 7: 29 case 8: 30 case 10: 31 case 12: 32 day = 31; 33 break; 34 case 2://由于2月有平年和闰年之分,所以要判断一下 35 if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) 36 { 37 day = 29; 38 } 39 else 40 { 41 day = 28; 42 } 43 break; 44 default: 45 day = 30; 46 break; 47 } 48 Console.WriteLine("{0}年{1}月有{2}天", year, month, day); 49 } 50 catch 51 { 52 Console.WriteLine("输入的月份有误,程序退出"); 53 } 54 55 } 56 catch 57 { 58 Console.WriteLine("输入的年份有误,程序退出"); 59 } 60 61 Console.ReadKey(); 62 } 63 } 64 }
标签:threading ace ram day span 输出 reading -- 练习
原文地址:https://www.cnblogs.com/LiyuLi/p/12080254.html