7.json 2.9 KB
Newer Older
每日一练社区's avatar
test  
每日一练社区 已提交
1
{
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  "question_id": 7449094,
  "question_title": "工龄问题求解,工龄 人数",
  "question_content": "<p>给定公司N名员工的工龄&#xff0c;要求按工龄增序输出每个工龄段有多少员工。输入首先给出正整数N&#xff0c;即员工总人数&#xff1b;\n随后给出N个整数&#xff0c;即每个员工的工龄&#xff0c;范围在[0, 99]。其中&#xff0c;0-9为第1个工龄段&#xff0c;10-19为第2个工龄段&#xff0c;…&#xff0c;90-99为第10个工龄段。按工龄的递增顺序输出每个工龄的员工个数&#xff0c;格式为&#xff1a;“工龄:人数”。每项占一行。如果人数为0则不输出该项。</p>",
  "difficulty": "简单",
  "answer_id": 53429153,
  "answer_content": "<pre>\n<code>#include&lt;stdio.h&gt;\nint main()\n{\n    int i,n,a[11]&#61; {0},x;\n    scanf(&#34;%d&#34;,&amp;n);\n    for(i&#61;0; i&lt;n; i&#43;&#43;)\n    {\n        scanf(&#34;%d&#34;,&amp;x);\n        if(x&lt;&#61;9)\n            a[1]&#43;&#43;;\n        else if(x&gt;9&amp;&amp;x&lt;&#61;19)\n            a[2]&#43;&#43;;\n        else if(x&gt;19&amp;&amp;x&lt;&#61;29)\n            a[3]&#43;&#43;;\n        else if(x&gt;29&amp;&amp;x&lt;&#61;39)\n            a[4]&#43;&#43;;\n        else if(x&gt;39&amp;&amp;x&lt;&#61;49)\n            a[5]&#43;&#43;;\n        else if(x&gt;49&amp;&amp;x&lt;&#61;59)\n            a[6]&#43;&#43;;\n        else if(x&gt;59&amp;&amp;x&lt;&#61;69)\n            a[7]&#43;&#43;;\n        else if(x&gt;69&amp;&amp;x&lt;&#61;79)\n            a[8]&#43;&#43;;\n        else if(x&gt;79&amp;&amp;x&lt;&#61;89)\n            a[9]&#43;&#43;;\n        else\n            a[10]&#43;&#43;;\n    }\n    for(i&#61;1;i&lt;&#61;10;i&#43;&#43;){\n        if(a[i]&gt;0){\n            printf(&#34;%d-%d:%d\\n&#34;,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_"
每日一练社区's avatar
test  
每日一练社区 已提交
19
}