{
"question_id": 7449094, "question_title": "工龄问题求解,工龄 人数", "question_content": "<p>给定公司N名员工的工龄,要求按工龄增序输出每个工龄段有多少员工。输入首先给出正整数N,即员工总人数;\n随后给出N个整数,即每个员工的工龄,范围在[0, 99]。其中,0-9为第1个工龄段,10-19为第2个工龄段,…,90-99为第10个工龄段。按工龄的递增顺序输出每个工龄的员工个数,格式为:“工龄:人数”。每项占一行。如果人数为0则不输出该项。</p>", "difficulty": "简单", "answer_id": 53429153, "answer_content": "<pre>\n<code>#include<stdio.h>\nint main()\n{\n int i,n,a[11]= {0},x;\n scanf("%d",&n);\n for(i=0; i<n; i++)\n {\n scanf("%d",&x);\n if(x<=9)\n a[1]++;\n else if(x>9&&x<=19)\n a[2]++;\n else if(x>19&&x<=29)\n a[3]++;\n else if(x>29&&x<=39)\n a[4]++;\n else if(x>39&&x<=49)\n a[5]++;\n else if(x>49&&x<=59)\n a[6]++;\n else if(x>59&&x<=69)\n a[7]++;\n else if(x>69&&x<=79)\n a[8]++;\n else if(x>79&&x<=89)\n a[9]++;\n else\n a[10]++;\n }\n for(i=1;i<=10;i++){\n if(a[i]>0){\n printf("%d-%d:%d\\n",i*10-10,i*10-1,a[i]);\n }\n }\n}\n</code></pre>\n\n<p><img alt=\"\" height=\"269\" src=\"https://img-ask.csdnimg.cn/upload/1623660087533.png\" width=\"642\" /></p>\n", "tag_name": "c语言", "cpp": "#include <stdio.h>\nint main()\n{\n\tint i,n,a[11]= {0},x;\n\tscanf(\"%d\",&n);\n\tfor(i=0; i<n; i++)\n\t{\n\t\tscanf(\"%d\",&x);\n\t\tif(x<=9)\n\t\t\ta[1]++;\n\t\telse if(x>9&&x<=19)\n\t\t\ta[2]++;\n\t\telse if(x>19&&x<=29)\n\t\t\ta[3]++;\n\t\telse if(x>29&&x<=39)\n\t\t\ta[4]++;\n\t\telse if(x>39&&x<=49)\n\t\t\ta[5]++;\n\t\telse if(x>49&&x<=59)\n\t\t\ta[6]++;\n\t\telse if(x>59&&x<=69)\n\t\t\ta[7]++;\n\t\telse if(x>69&&x<=79)\n\t\t\ta[8]++;\n\t\telse if(x>79&&x<=89)\n\t\t\ta[9]++;\n\t\telse\n\t\t\ta[10]++;\n\t}\n\tfor(i=1;i<=10;i++){\n\t\tif(a[i]>0){\n\t\t\tprintf(\"%d-%d:%d\\n\",i*10-10,i*10-1,a[i]);\n\t\t}\n\t}\n}", "topic_link": "https://bbs.csdn.net/topics/600470245", "status": 1, "keywords": "算法初阶,排序和顺序统计量,中位数和顺序统计量", "license": "csdn.net", "notebook": { "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/7.ipynb?type=file" }, "notebook_enable": 1, "author": "Flyyyy_"
}