50172. Stairs
難度:2.5/51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void print_stars(int cnt){
    for(int i = 0; i < cnt; i++) printf("*");
}
int main(){
    int now_len = 0;
    int is_hor = 1;
    int flag = 0;
    char last = '$';
    char s[128] = {0};
    while(scanf("%s", s) != EOF){
        int n = strlen(s);
        if(is_hor){
            if(flag == 0){
                printf("%s\n", s);
                now_len += n - 1;
                flag = 1;
            }
            else if(s[0] != last){
                printf("\n");
                print_stars(now_len);
                printf("%s\n", s);
                now_len += n - 1;
            }
            else{
                printf("%s\n", s + 1);
                now_len += n - 1;
            }
        }
        else{
            if(s[0] != last){
                for(int i = 0; i < n; i++){
                    print_stars(now_len);
                    printf("%c", s[i]);
                    if(i != n - 1) printf("\n");
                }
            }
            else{
                for(int i = 1; i < n; i++){
                    print_stars(now_len);
                    printf("%c", s[i]);
                    if(i != n - 1) printf("\n");
                }
            }
        }
        last = s[n - 1];
        is_hor ^= 1;
    }
}