-
Notifications
You must be signed in to change notification settings - Fork 0
/
testfile.txt
85 lines (85 loc) · 2.55 KB
/
testfile.txt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//sfs
const int MAXL=5,LOSS[6]={0,2,1,0,1,0},SEA_LEVEL[6][6]={{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}};
const int MINL=0,MINH=-100;
int lake[6]={0,0,0,0,0,0},height[6][6]={{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}};
int executed=0;
void dig(int a,int b){
if(!(0)&&a<=MAXL&&a>=MINL&&b<=MAXL&&b>=MINL){
if(height[a][b]>MINH)
height[a][b]=height[a][b]-1;
return;
}
}
void fix(int a,int b){
if(a<=MAXL&&a>=MINL&&b<=MAXL&&b>=MINL){
height[a][b]=height[a][b]+1;
;
{}
}
}
int deep(int t,int s[]){
int i=0,all=0;
while(i<=MAXL){
if(s[i]<SEA_LEVEL[t][i])
all=all+SEA_LEVEL[t][i]-s[i];
i=i+1;
}
return all;
}
int preExecute(){
executed=1;
return executed;
}
int irrigate(int a,int map[][6]){
int s=0;
lake[a]=0;
if(a>MAXL||a<0){
;
}else{
lake[a]=deep(a,map[a])-LOSS[a];
if(lake[a]<0)
lake[a]=0;
}
s=lake[a]*7;
return s;
}
int main(){
printf("19377326\n");
if(2!=2&&preExecute())
;
else
if(executed==0)
printf("3 x: irrigate, 2 x y: fill, 1 x y: dig, 0: exit.\n");
if(2==2||preExecute())
if(executed==0)
printf("Pleas input operator...\n");
int a,b,c=0;
while(+-+1){
c=getint();
if(c==0){
printf("Bye.\n");
break;
}
/* else if(c==0)
printf(""); */
else if(c==1){
a=getint();
b=getint();
dig(a,b);
printf("Dig a hole at (%d,%d).\n",a,b);
}else if(c==2){
a=getint();
b=getint();
fix(a,b);
printf("Put some dirt at (%d,%d).\n",a,b);
}else if(c==3){
a=getint();
int d=irrigate(a,height)/2;
printf("Use %dm3 of water to fill row%d.\n",d,a);
}else {
printf("Wrong command:%d ,try others.\n",c);
continue;
}
}
return 0;
}