-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.c
42 lines (36 loc) · 830 Bytes
/
snake.c
1
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
#include<stdio.h>
int main(){
int m, n;
scanf("%d %d",&m,&n);
int end = 1;
for(int i = 1; i <=m; i++){
for(int j = 1; j <= n; j++){
if(i%2 != 0){
printf("#");
}else{
if(end){
if(j == n){
printf("#");
}else{
printf(".");
}
}else{
if(j == 1){
printf("#");
}else{
printf(".");
}
}
}
}
if(i%2 == 0){
if(end == 1){
end = 0;
}else{
end = 1;
}
}
printf("\n");
}
return 0;
}