C#基础-017 简单练习-循环
来源:互联网 发布:阿里云解析的别名在哪 编辑:程序博客网 时间:2024/05/20 04:10
namespace 作业{ class Program { static void Main(string[] args) { Console.WriteLine("请输入一个数字:"); int day = int.Parse(Console.ReadLine()); switch (day) { case 1: case 2: case 3: case 4: case 5: Console.WriteLine("今天是工作日"); break; case 6: case 7: Console.WriteLine("今天是休息日"); break; default: Console.WriteLine("您的输入无效"); break; } Console.WriteLine("请输入成绩"); int score = int.Parse(Console.ReadLine()); if (score > 100 || score < 0) { Console.WriteLine("输入不合法"); } else // 表示 score<=100 && score>=0 { switch (score / 10) { case 10: Console.WriteLine("满分"); break; case 9: Console.WriteLine("优秀"); break; case 8: case 7: Console.WriteLine("良好"); break; case 6: Console.WriteLine("及格"); break; default: Console.WriteLine("不及格"); break; } } Console.WriteLine("选择性别0:男\t1:女"); int gender = int.Parse(Console.ReadLine()); Console.WriteLine("请输入体重"); int weight = int.Parse(Console.ReadLine()); Console.WriteLine("请输入身高"); int height = int.Parse(Console.ReadLine()); //记录标准的体重 int standerWeight = 0; switch (gender) { case 0: standerWeight = height - 105; break; case 1: standerWeight = height - 100; break; default: Console.WriteLine("不存在此性别"); break; } float rate = weight * 1.0f / standerWeight; if (rate < 0.6f) { Console.WriteLine("严重营养不良"); } else if (rate < 0.8f) // rate>=0.6 && rate<0.8 { Console.WriteLine("中度营养不良"); } else if (rate < 0.9) { Console.WriteLine("轻度营养不良"); } else if (rate < 1.1) { Console.WriteLine("正常"); } else if (rate < 1.2) { Console.WriteLine("轻度肥胖"); } else { Console.WriteLine("肥胖"); } Console.WriteLine("请输入学员成绩"); int score = int.Parse(Console.ReadLine()); char level = 'A'; switch (score / 10) { case 10: case 9: level = 'A'; break; case 8: level = 'B'; break; case 7: level = 'C'; break; case 6: level = 'D'; break; default: level = 'E'; break; } Console.WriteLine(level); Console.WriteLine("请输入年份"); int year = int.Parse(Console.ReadLine()); Console.WriteLine("请输入月份"); int month = int.Parse(Console.ReadLine()); Console.WriteLine("请输入日期"); int days = int.Parse(Console.ReadLine()); //记录累加的天数 //2 20 int totalDays = 0; totalDays += days; month -= 1; if (month==11) { totalDays += 30; month -= 1; } if (month == 10) { totalDays += 31; month -= 1; } if (month == 9) { totalDays += 30; month -= 1; } if (month == 8) { totalDays += 31; month -= 1; } if (month == 7) { totalDays += 31; month -= 1; } if (month == 6) { totalDays += 30; month -= 1; } if (month == 5) { totalDays += 31; month -= 1; } if (month == 4) { totalDays += 30; month -= 1; } if (month == 3) { totalDays += 31; month -= 1; } //能执行下面的if条件的 肯定是大于2月份的 if (month == 2) { totalDays += 28; month -= 1; //判断是否为闰年 是闰年再加1 if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { totalDays++; } } if (month == 1) { totalDays += 31; month -= 1; } Console.WriteLine("这是今年的第{0}天",totalDays); } }}
阅读全文
0 0
- C#基础-017 简单练习-循环
- C#基础-015 简单循环goto-start
- Java:基础练习-循环练习
- C#循环练习
- 简单程序循环练习
- js基础for循环练习
- c#基础练习
- c#基础练习
- C#基础练习
- C#基础-016 循环
- io基础,简单练习
- C#简单循环
- Java 基础 for循环基础练习记录
- C#基础-023 综合练习
- java基础-循环练习-打印出月历
- Web 基础学习之 JS ,循环练习
- PL/SQL语言循环简单语句练习
- 分享一些简单的for循环练习
- Python学习笔记 2
- cin,cin.get,cin.getline,getline的区别
- 杨辉三角形
- 网络流征程——ISAP算法
- zepto知识点总结
- C#基础-017 简单练习-循环
- 2017/8/25 训练总结(最终版QAQ)
- linux上配置eclipse
- 二叉查找树的c++实现
- Linux编译内核执行make menuconfig或者make xconfig出错
- 二维数组案例
- ReactNative基础---State and Lifecycle
- 小随笔 SQL语句中的条件判断CASE
- php的public、protected、private三种访问控制模式的区别