PAT 1031 Hello World for U

http://pat.zju.edu.cn/contests/pat-practise/1031

模拟题

 1 #include <stdio.h>
 2 #include <string.h>
 3 char words[100];
 4 int main()
 5 {
 6     scanf("%s",words);
 7     //先确定底部的长度
 8     int i;
 9     int n2;
10     for(i=3;;i++) {
11         if((strlen(words)-i)%2==0&&((strlen(words)-i)/2+1<=i)){
12             n2=i;
13             break;
14         }
15     }
16 
17 //    int n2=i;
18     int height=(strlen(words)-i)/2;
19 
20     char *p=words;
21     char *q=words+strlen(words)-1;
22 
23     while(height--) {
24         putchar(*p);
25         p++;
26         int i;
27         for(i=1;i<=n2-2;i++)    putchar(' ');
28         putchar(*q);
29         putchar('\n');
30         q--;
31     }
32     while(n2--) {
33         putchar(*p);
34         p++;
35     }
36     putchar('\n');
37     return 0;
38 }
39     
原文地址:https://www.cnblogs.com/yangce/p/2546586.html