{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "e0ed26c00e394a4bb732453c9cf34c85",
  "keywords": "桶排序,算法初阶,线性时间排序,排序和顺序统计量",
  "title": "一个整数的序列，要求对其重新排序",
  "desc": [
    {
      "content": "\n<p>一个整数的序列&#xff0c;要求对其重新排序。排序要求:\n1.奇数在前&#xff0c;偶数在后&#xff1b;\n2.奇数按从大到小排序&#xff1b;\n3.偶数按从小到大排序。<br />\n输入一行&#xff0c;包含整数个数n&#xff0c; n个整数值&#xff0c;彼此以一个空格分开。\n按照要求排序后输出一行&#xff0c;包含排序后的n 个整数。\n</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <iostream>\n#include <algorithm>\nusing namespace std;\nbool cmp(int a, int b){\n    int x = a % 2;\n    int y = b % 2;\n    if(x == y)\n        if(x == 0)\n            return a < b;\n        else\n            return a > b;\n    else\n        return x > y;\n}\nint main()\n{\n    int n, i;\n    cin >> n;\n    int a[n];\n    for(i = 0; i < n; i++)\n        cin >> a[i];\n    sort(a, a+n, cmp);\n    for(i = 0; i < n; i++)\n        cout << a[i] << \" \";\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-18b330b06c254136bf00850f53290b0b",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600470146"
}