{
  "question_id": 7436200,
  "question_title": "数组排序",
  "question_content": "定义一个包含5个整型元素(1, 5, 3, 92, 6)的数组,将数组元素按照由 小到大的顺序输出",
  "difficulty": "简单",
  "answer_id": 53407715,
  "answer_content": "<p>代码如下&#xff0c;如有帮助&#xff0c;请采纳一下&#xff0c;谢谢。</p>\n\n<pre>\n<code>#include &lt;stdio.h&gt;\n\n#define N (int)5\n\nint main()\n{\n\tint a[N] &#61; {1,5,3,92,6};\n\tint tmp;\n\tfor (int i &#61; 0; i &lt; N-1; i&#43;&#43;)\n\t{\n\t\tfor (int j &#61; 0;j &lt; N-1-i;j&#43;&#43;)\n\t\t{\n\t\t\tif (a[j] &gt; a[j&#43;1])\n\t\t\t{\n\t\t\t\ttmp &#61; a[j];\n\t\t\t\ta[j] &#61; a[j&#43;1];\n\t\t\t\ta[j&#43;1] &#61; tmp;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i &#61; 0; i &lt; N; i&#43;&#43;)\n\t{\n\t\tprintf(&#34;%d &#34;,a[i]);\n\t}\n\t//getchar();\n\t//getchar();\n\treturn 0;\n}</code></pre>\n\n<p> </p>\n",
  "tag_name": "c语言",
  "cpp": "#include <stdio.h>\n#define N (int)5\nint main()\n{\n\tint a[N] = {1,5,3,92,6};\n\tint tmp;\n\tfor (int i = 0; i < N-1; i++)\n\t{\n\t\tfor (int j = 0;j < N-1-i;j++)\n\t\t{\n\t\t\tif (a[j] > a[j+1])\n\t\t\t{\n\t\t\t\ttmp = a[j];\n\t\t\t\ta[j] = a[j+1];\n\t\t\t\ta[j+1] = tmp;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < N; i++)\n\t{\n\t\tprintf(\"%d \",a[i]);\n\t}\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470264",
  "status": 1,
  "keywords": "算法初阶,排序和顺序统计量,中位数和顺序统计量",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/64.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "DropOcean"
}