{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "2b2ef20f0be545bf89115f683d131db8", "keywords": "B树,算法高阶,高级数据结构,B树上的基本操作", "title": "if else 和 switch 使用", "desc": [ { "content": "\n
输入学生成绩,\n若成绩在95分以上,输出“A”;\n若成绩在85~94分,输出“B”;\n若成绩在75~84分,输出“C”;\n若成绩在65~74分,输出“D”;\n若成绩在65分以下,输出“E”。(分别用if else 和 switch 语句完成)
", "language": "markdown" } ], "answer": [ { "content": "", "language": "cpp" } ], "prepared": [ [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ] ], "template": { "content": "#include \"stdio.h\" \nint main(){\n\tint score;\n\tscanf(\"%d\",&score);\n\tif(score>=95){\n\t\tprintf(\"A\\n\");\t\n\t}else if(score>=85 && score<=94){\n\t\tprintf(\"B\\n\");\n\t}else if(score>=75 && score<=84){\n\t\tprintf(\"C\\n\");\n\t}else if(score>=65 && score<=74){\n\t\tprintf(\"D\\n\");\n\t}else{\n\t\tprintf(\"E\\n\");\n\t}\n\tprintf(\"以下用switch语句实现相同功能\\n\");\n\tscore = score-5;\n\tscore = score/10;\n\tswitch(score){\n\t\tcase 9:\n\t\t\tprintf(\"A\\n\");\t\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tprintf(\"B\");\t\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tprintf(\"C\\n\");\t\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tprintf(\"D\\n\");\t\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tprintf(\"E\\n\");\n\t\t\tbreak;\n\t}\n}", "language": "cpp" }, "node_id": "dailycode-76e2e197fa8044a5939dc87d01245e2d", "license": "csdn.net", "created_at": 1637894160, "topic_link": "https://bbs.csdn.net/topics/600470148" }