#include <iostream>
using namespace std;

int main() {
    string s;
    while (cin >> s) {
        int n = 0, m = 0;
        int N = s.length();
        for (int i = N ; i >0; i--) {
            for (int j = 0; j < N ; j++) {
                if (2 * i + j == N && i < j) {   // 修正条件
                    n = i;//共有n个n1
                    m = j;//m个n2
                    goto end;
                }
            }
        }
    end:
        for (int i = 0; i < N; i++) {
            int t = m;
            if (i < n) {   // 前 n 行,每行左右字符
                cout << s[i];
                while (t - 2 > 0) {
                    cout << " ";
                    t--;
                }
                cout << s[N - 1 - i] << endl;
            }
            else if (i >= n && i <n+m) {   // 底边连续字符
                cout << s[i];
            }
        }
        cout << endl;
    }
}

1,使用goto跳出双for循环

2,.length()表示的是字符长度,注意区分数组索引和长度