{
  "question_id": 1057457,
  "question_title": "输入一个正整数n（代表图形的行数），输出如样例形式的图形。",
  "question_content": "输入：7\n输出：\n        D      D\n        CD    DC\n        BCD  DCB\n        ABCDDCBA\n        BCD  DCB\n        CD    DC\n        D      D",
  "difficulty": "简单",
  "answer_id": 1254605,
  "answer_content": "\n```\n#include<stdio.h>\n#include<vector>\n#include<string>\n#include<iostream>\n#include<algorithm>\nusing namespace std;\nint main() {\n\tint n;\n\tcin>>n;\n\tvector<string> a(n,\"\"),b(n,\"\");\n\tint m=(n+1)/2;\n\tint p=0;\n\tfor(int i=m-1;i>=0;i--){\n\t\tfor(int j=0;j<=i;j++)\n\t\t\ta[i].push_back('A'+j+p);\n\t\tb[i]=a[i];\n\t\treverse(b[i].begin(),b[i].end());\n\t\tfor(int j=i+1;j<m;j++){\n\t\t\ta[i]+=\" \";\n\t\t\tb[i]+=\" \";\n\t\t}\n\t\tp++;\n\t}\n\tp=0;\n\tfor(int i=n-1;i>=m;i--){\n\t\ta[i]=a[p];\n\t\tb[i]=b[p++];\n\t}\n\tfor(int i=0;i<n;i++)\n\t\tcout<<a[i]<<b[i]<<endl;\n\treturn 0;\n}\n```",
  "tag_name": "c++",
  "cpp": "#include<stdio.h>\n#include<vector>\n#include<string>\n#include<iostream>\n#include<algorithm>\nusing namespace std;\nint main() {\n\tint n;\n\tcin>>n;\n\tvector<string> a(n,\"\"),b(n,\"\");\n\tint m=(n+1)/2;\n\tint p=0;\n\tfor(int i=m-1;i>=0;i--){\n\t\tfor(int j=0;j<=i;j++)\n\t\t\ta[i].push_back('A'+j+p);\n\t\tb[i]=a[i];\n\t\treverse(b[i].begin(),b[i].end());\n\t\tfor(int j=i+1;j<m;j++){\n\t\t\ta[i]+=\" \";\n\t\t\tb[i]+=\" \";\n\t\t}\n\t\tp++;\n\t}\n\tp=0;\n\tfor(int i=n-1;i>=m;i--){\n\t\ta[i]=a[p];\n\t\tb[i]=b[p++];\n\t}\n\tfor(int i=0;i<n;i++)\n\t\tcout<<a[i]<<b[i]<<endl;\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470182",
  "status": 1,
  "keywords": "算法,图形输出",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/134.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "qq_32565003"
}