PAT A 1031 Hello World for U

#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main()
{
    char str[100];
    scanf("%s",str);
    int len=strlen(str);
    int n1,n2,n=0,i=1;
    while(3*i<=len+2) i++;
    n1=i-1;
    n2=len+2-2*n1;
    for(i=1;i<n1;i++,n++){
        printf("%c",str[n]);
        for(int j=0;j<n2-2;j++)    printf(" ");    //space
        printf("%c\n",str[len-1-n]);
    }
    for(i=n;i<n1+n2-1;i++)             printf("%c",str[i]);
    return 0;
}

上一篇:1031 Hello World for U


下一篇:1031 Hello World for U (20分)