check map2
Dependencies: mbed
Fork of 3DArray2 by
Revision 1:52ec50a0aac5, committed 2016-12-04
- Comitter:
- silvermist
- Date:
- Sun Dec 04 10:50:04 2016 +0000
- Parent:
- 0:151948e45f6a
- Commit message:
- xc
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 151948e45f6a -r 52ec50a0aac5 main.cpp --- a/main.cpp Sat Dec 03 18:43:42 2016 +0000 +++ b/main.cpp Sun Dec 04 10:50:04 2016 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" -int map[5][5][5]; -int i , j , k , player , button , x ,y , z; +int map[5][5][5],rmap[5][5][5]; +int i , j , k , player , button , turn; int check1[5][5][5] , check2[5][5][5]; void Check_case1(){ //คนแรกชนะ @@ -22,18 +22,18 @@ } void Check_map(){ //แสดงmap - for(x=0 ; x<5 ; x++){ - for(y=0 ; y<5 ; y++){ - for(z=0 ; z<5 ; z++){ - if(map[x][y][z] == 5){ - check1[x][y][z] = 1; + for(i=0 ; i<5 ; i++){ + for(j=0 ; j<5 ; j++){ + for(k=0 ; k<5 ; k++){ + if(map[i][j][k] == 5){ + check1[i][j][k] = 1; } - else if(map[x][y][z] == 6){ - check2[x][y][z] = 1; + else if(map[i][j][k] == 6){ + check2[i][j][k] = 1; } else{ - check1[x][y][z] = 0; - check2[x][y][z] = 0; + check1[i][j][k] = 0; + check2[i][j][k] = 0; } } } @@ -49,6 +49,7 @@ i-- , j-- , k--; if(map[i][j][k] == 0){ map[i][j][k] = 5; // 5 = 'x' + turn++; } else{ Check_error(); // ลงไมไ่ด้ @@ -57,6 +58,7 @@ i-- , j-- , k--; if(map[i][j][k] == 0){ map[i][j][k] = 6; // 6 = 'o' + turn++; } else{ Check_error(); // ลงไมไ่ด้ @@ -64,7 +66,7 @@ } if(i == 5 or j == 5 or k == 5){ // ลงเกิน map - check_error(); + Check_error(); } for(i=0 ; i<5 ; i++){ //แนว k