{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "551715871e814d718500f8cc0bb3ade3",
  "keywords": "算法,排序",
  "title": "按字典顺序排列问题",
  "desc": [
    {
      "content": "\n输入若干英文单词，将每个单词的首字母转换成大写字母，其他字母为小写，并按字典顺序排列",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": " #include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\nint cmp(const void * a, const void * b)\n{\n\treturn strcmp(*(char **)a, *(char **)b);\n}\nint main(int argc, char* argv[])\n{\n\tint n = 0;\n\tint i;\n\tprintf(\"how many words?\\n\");\n\tscanf(\"%d\", &n);\n\tchar ** s = new char *[n];\n\tfor (i = 0; i < n; i++)\n\t{\n\t\ts[i] = new char[100];\n\t\tscanf(\"%s\", s[i]);\n\t\tchar * t = s[i];\n\t\twhile (*t != '\\0')\n\t\t{\n\t\t\tif (t == s[i] && (*t >= 'a' && *t <= 'z')) *t = *t - 'a' + 'A';\n\t\t\tif (t > s[i] && (*t >= 'A' && *t <= 'Z')) *t = *t - 'A' + 'a';\n\t\t\tt++;\n\t\t}\n\t}\n\tqsort(s, n, sizeof(char *), cmp);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tprintf(\"%s\\n\", s[i]);\n\t}\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-dab42155788f4df992f7bee3d2ceaff3",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600470273"
}