Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.   int n = 0;
  6.   int board[150][150];
  7.   int counter = 0;
  8.   int maxCounter = counter + n;
  9.   int positionCounter = 0;
  10.  
  11.   scanf("%d", &n);
  12.  
  13.   if (n >= 1 && n <= 100) {
  14.  
  15.     if (n == 1) {
  16.       scanf("%d", &board[0][0]);
  17.       printf("Yay\n");
  18.     } else {
  19.  
  20.       for (int i = 0; i < n; i++) {
  21.         for (int j = 0; j < n; j++) {
  22.           scanf("%d", &board[i][j]);
  23.         }
  24.       }
  25.  
  26.       int numberic[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  27.       int countNumbericHorizontal[10] = {0};
  28.       int countNumbericVertical[10] = {0};
  29.       int hasSameNumberInHorizontal = 0;
  30.       int hasSameNumberInVertical = 0;
  31.  
  32.       for (int i = 0; i < n; i++) {
  33.  
  34.         // Set all counter to 0
  35.         for (int k = 0; k < 10; k++) {
  36.           countNumbericHorizontal[k] = 0;
  37.           countNumbericVertical[k] = 0;
  38.         }
  39.  
  40.         // Check Horizontal and Vertical
  41.         for (int j = 0; j < n; j++) {
  42.           for (int k = 0; k < n; k++) {
  43.             if (k != j) {
  44.               if (board[i][j] == board[i][k]) {
  45.                 countNumbericHorizontal[board[i][j]] += 1;
  46.               }
  47.               if (board[j][i] == board[k][i]) {
  48.                 countNumbericVertical[board[j][i]] += 1;
  49.               }
  50.             }
  51.  
  52.             // countNumbericHorizontal[board[i][j]] += 1;
  53.             // countNumbericVertical[board[j][i]] += 1;
  54.           }
  55.  
  56.           // board[i][j] to right
  57.           // board[j][i] to bottom
  58.          
  59.         }
  60.  
  61.         // Check same number
  62.         for (int k = 0; k < 10; k++) {
  63.           if (countNumbericHorizontal[k] > 1) {
  64.             hasSameNumberInHorizontal = 1;
  65.           }
  66.  
  67.           if (countNumbericVertical[k] > 1) {
  68.             hasSameNumberInVertical = 1;
  69.           }
  70.         }
  71.  
  72.         // printf("Horizontal: %d\n", hasSameNumberInHorizontal);
  73.         // printf("Vertical: %d\n", hasSameNumberInVertical);
  74.       }
  75.  
  76.       if (hasSameNumberInHorizontal || hasSameNumberInVertical) {
  77.         printf("Nay\n");
  78.       } else {
  79.         printf("Yay\n");
  80.       }
  81.     }
  82.   }
  83.  
  84.   return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement