{
"question_id": 237824, "question_title": "统计某一单科成绩各分数段的分布人数", "question_content": "设某班有若干人,写一程序统计某一单科成绩各分数段的分布人数,每人的成绩随机输入,输入负数表示输入结束。要求按下面的格式输出统计结果(“**”表示实际分布人数)\n0~39\t**\n40~49\t**\n50~59\t**\n……\n90~100\t**", "difficulty": "简单", "answer_id": 218762, "answer_content": "这是上课题目?\n```\n #include <string>\n#include <iostream>\nusing namespace std;\nint main()\n{\n int result[12] = {0};\n int gold;\n while (cin>>gold) {\n if (gold < 0) {\n break;\n }\n \n int code = gold / 10;\n if (code < 4) {\n result[3] ++;\n }\n else if(code == 10) {\n result[9] ++;\n }\n else {\n result[code] ++;\n }\n }\n \n string word[] = {\"0~39\",\n \"40~49\",\n \"50~59\",\n \"60~69\",\n \"70~79\",\n \"80~89\",\n \"90~100\"};\n \n for (int i=0; i<7; i++) {\n cout<<word[i]<<\" \"<<result[i+3]<<endl;\n }\n \n return 0;\n}\n```\n这样写应该还好理解\n", "tag_name": "c++", "cpp": "#include <string>\n#include <iostream>\nusing namespace std;\nint main()\n{\n\tint result[12] = {0};\n\tint gold;\n\twhile (cin>>gold) {\n\t\tif (gold < 0) {\n\t\t\tbreak;\n\t\t}\n\t\tint code = gold / 10;\n\t\tif (code < 4) {\n\t\t\tresult[3] ++;\n\t\t}\n\t\telse if(code == 10) {\n\t\t\tresult[9] ++;\n\t\t}\n\t\telse {\n\t\t\tresult[code] ++;\n\t\t}\n\t}\n\tstring word[] = {\"0~39\",\n\t\"40~49\",\n\t\"50~59\",\n\t\"60~69\",\n\t\"70~79\",\n\t\"80~89\",\n\t\"90~100\"};\n\tfor (int i=0; i<7; i++) {\n\t\tcout<<word[i]<<\" \"<<result[i+3]<<endl;\n\t}\n\treturn 0;\n}", "topic_link": "https://bbs.csdn.net/topics/600470170", "status": 1, "keywords": "算法初阶,基础知识,随机算法,概率分析和随机算法", "license": "csdn.net", "notebook": { "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/87.ipynb?type=file" }, "notebook_enable": 1, "author": "lionta2014"
}