其他分享
首页 > 其他分享> > 1031 Hello World for U (20分)

1031 Hello World for U (20分)

作者:互联网

1031 Hello World for U (20分)

#include <iostream>
#include <string.h>
using namespace std;
int main() {
    char c[81], u[30][30];
    memset(u, ' ', sizeof(u));
    scanf("%s", c);
    int n = strlen(c) + 2;
    int n1 = n / 3, n2 = n / 3 + n % 3, index = 0;
    for(int i = 0; i < n1; i++) u[i][0] = c[index++];
    for(int i = 1; i <= n2 - 2; i++) u[n1-1][i] = c[index++];
    for(int i = n1 - 1; i >= 0; i--) u[i][n2-1] = c[index++];
    for(int i = 0; i < n1; i++) {
        for(int j = 0; j < n2; j++) 
            printf("%c", u[i][j]);
        printf("\n");
    }
    return 0;
}
//柳神代码 存到二维数组中直接输出

  

标签:index,20,int,printf,++,n1,World,n2,1031
来源: https://www.cnblogs.com/1012wenquan66/p/13698958.html