Advertisement
SAMonna

Tic-tac-toe

Nov 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3. char t1, t2, t3;
  4. char t4, t5, t6;
  5. char t7, t8, t9;
  6.  
  7. scanf("%c %c %c ", &t1, &t2, &t3);
  8. scanf("%c %c %c ", &t4, &t5, &t6);
  9. scanf("%c %c %c", &t7, &t8, &t9);
  10.  
  11. if((t1 == 'x' && t2 == 'x' && t3 == 'x') || (t1 == 'x' && t4 == 'x' && t7 == 'x') ||
  12. (t1 == 'x' && t5 == 'x' && t9 == 'x') || (t4 == 'x' && t5 == 'x' && t6 == 'x') ||
  13. (t2 == 'x' && t5 == 'x' && t8 == 'x') || (t3 == 'x' && t5 == 'x' && t7 == 'x') ||
  14. (t7 == 'x' && t8 == 'x' && t9 == 'x'))
  15. {
  16. printf("Player1 win\n");
  17.  
  18. }
  19. else if ((t1 == '.' && t2 == '.' && t3 == '.')|| (t1 == '.' && t4 == '.' && t7 == '.') ||
  20. (t1 == '.' && t5 == '.' && t9 == '.') || (t4 == '.' && t5 == '.' && t6 == '.') ||
  21. (t2 == '.' && t5 == '.' && t8 == '.') || (t3 == '.' && t5 == '.' && t7 == '.') ||
  22. (t7 == '.' && t8 == '.' && t9 == '.'))
  23. {
  24. printf("Player2 win\n");
  25.  
  26. } else
  27. {
  28. printf("No result\n");
  29. }
  30.  
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement