Advertisement
Guest User

Untitled

a guest
May 7th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. /*
  2. switch (entered) {
  3. case 1: if (tic[0][0] != 0) {tic[0][0] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  4. case 2: if (tic[0][1] != 0) {tic[0][1] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  5. case 3: if (tic[0][2] != 0) {tic[0][2] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  6. case 4: if (tic[1][0] != 0) {tic[1][0] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  7. case 5: if (tic[1][1] != 0) {tic[1][1] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  8. case 6: if (tic[1][2] != 0) {tic[1][2] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  9. case 7: if (tic[2][0] != 0) {tic[2][0] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  10. case 8: if (tic[2][1] != 0) {tic[2][1] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  11. case 9: if (tic[2][2] != 0) {tic[2][2] = 0; uswitcher = 1;} else {cout << "Invalid\n"; uswitcher = 0; continue;} break;
  12. }
  13. */
  14.  
  15. int x = (entered - 1) % 3;
  16. int y = (entered - 1) / 3;
  17. if (tic[y][x] != 0)
  18. {
  19.     tic[y][x] = 0;
  20.     uswitcher = 1;
  21. }
  22. else
  23. {
  24.     cout << "Invalid\n";
  25.     uswitcher = 0;
  26.     continue;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement