{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "6fe0402a3ed24db89b062d4facb32c96", "keywords": "算法初阶,快速排序,快速排序的描述,排序和顺序统计量", "title": "数字归类", "desc": [ { "content": "\n题目描述\n一个数里面若含有数字1,则归类到1字类,含有数字2,则归类到2字类,所以一个数可能同时归类到不同的数字类。对于0、1、2、3、4、5、6、7、8、9这十个数字类,因研究需要,急于想知道某一堆数中,究竟归类到这些数字类的个数。\n样例输入\n123 456 175 2 61 9998 12 5053 382\n样例输出\n0: 1\n1: 4\n2: 4\n3: 3\n4: 1\n5: 3\n6: 2\n7: 1\n8: 2\n9: 1\n提示\n注意:输出结果中冒号后面有空格", "language": "markdown" } ], "answer": [ { "content": "", "language": "cpp" } ], "prepared": [ [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ] ], "template": { "content": "#include \n#include \nint result[10];\nint main(void) {\n\tmemset(result, 0, sizeof(int) * 10);\n\tint n;\n\tint arr[10];\n\twhile (scanf(\"%d\", &n) != EOF)\n\t{\n\t\tmemset(arr, 0, sizeof(int) * 10);\n\t\tif (n == 0) arr[0] = 1;\n\t\twhile (n > 0)\n\t\t{\n\t\t\tarr[n % 10] = 1;\n\t\t\tn = n / 10;\n\t\t}\n\t\tfor (int i = 0; i < 10; i++)\n\t\t\tresult[i] += arr[i];\n\t}\n\tfor (int i = 0; i < 10; i++)\n\t\tprintf(\"%d: %d\\n\", i, result[i]);\n\treturn 0;\n}", "language": "cpp" }, "node_id": "dailycode-04771a9a92f54cb1b4125e4528c6a193", "license": "csdn.net", "created_at": 1637894158, "topic_link": "https://bbs.csdn.net/topics/600469856" }