acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 题解

    userId_undefined

    码农爱历史

    倔强青铜
    12阅读
    0回复
    0点赞
  • 题解

    #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1010; char str[N][N]; int len[N]; int main () { int cnt = 0,mx = -1; while(gets(str[cnt])) { len[cnt] = strlen(str[cnt]); mx = max(mx,len[cnt]); cnt++; } cnt--; string a(mx+2,''); cout << a << endl; bool bt = false; for (int i = 0;i <= cnt;i++) { cout << ''; if (len[i] == 0) { for (int j = 1;j <= mx;j++) cout << " "; } else { int mid; if ((mx - len[i]) % 2 == 1) { if (bt == false) { mid = (mx - len[i] - 1) / 2; for (int j = 1;j <= mid;j++) cout << " "; cout << str[i]; for (int j = 1;j <= mid+1;j++) cout << " "; bt = true; } else { mid = (mx - len[i] + 1) / 2; for (int j = 1;j <= mid;j++) cout << " "; cout << str[i]; for (int j = 1;j <= mid-1;j++) cout << " "; bt = false; } } else { mid = (mx - len[i]) / 2; for (int j = 1;j <= mid;j++) cout << " "; cout << str[i]; for (int j = 1;j <= mid;j++) cout << " "; } } cout << "*\n"; } cout << a << endl; return 0; }

    userId_undefined

    滚吧c++

    倔强青铜
    7阅读
    0回复
    0点赞
首页