-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFox_and_snake.cpp
More file actions
50 lines (44 loc) · 891 Bytes
/
Fox_and_snake.cpp
File metadata and controls
50 lines (44 loc) · 891 Bytes
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
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
int32_t main(){
int n,m;
cin>>n>>m;
// n odd .. snake represented as '#'
// spaces as '.'
char snake[n][m]={'#'};
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(i%2!=0)snake[i][j]='.';
else snake[i][j]='#';
}
}
/* ans:
####
...#
####
#...
####
####
####
####
####
####
*/
int flag=0;
for(int i=1;i<n;i+=2){
if(flag==0){
snake[i][m-1]='#';
flag=1;
}else{
snake[i][0]='#';
flag=0;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<snake[i][j];
}
cout<<'\n';
}
return 0;
}