#include<iostream>
#include<cstring>
#include<queue>
using namespace std;


int main()
{
    char str[100];
    int len,n1,n2;
    cin>>str;
    len = strlen(str);

    //先求出n1和n2
    if( (len-1)%2 == 0 )
    {
        n1 = (len-1)/2;
        n2 = 3;
    }
    else
    {
        n1 = (len-2)/2;
        n2 = 4;
    }
    while( n1>n2 )
    {
        n1--;
        n2 += 2;
    }


    int b=0,e=len-1,i=0,j=0;
    for(i=0; i<n1; i++)
    {
        if(i==n1-1) //最后一行
        {
            for(j=0; j<n2; j++)
                cout<<str[b++];
            cout<<endl;
        }
        else
        {
            for(j=0; j<n2; j++)
            {
                if(j==0)
                    cout<<str[b++];
                else if(j==n2-1)
                    cout<<str[e--];
                else
                    cout<<" ";
            }
            cout<<endl;
        }

    }
    return 0;
}

相关文章:

  • 2022-12-23
  • 2021-05-11
  • 2021-04-02
  • 2021-09-21
  • 2022-02-25
  • 2021-10-05
  • 2022-12-23
  • 2021-09-05
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2021-12-07
  • 2021-07-16
  • 2021-04-12
  • 2022-01-22
  • 2022-12-23
相关资源
相似解决方案