Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- int n = 0;
- int board[150][150];
- int counter = 0;
- int maxCounter = counter + n;
- int positionCounter = 0;
- scanf("%d", &n);
- if (n >= 1 && n <= 100) {
- if (n == 1) {
- scanf("%d", &board[0][0]);
- printf("Yay\n");
- } else {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- scanf("%d", &board[i][j]);
- }
- }
- int numberic[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- int countNumbericHorizontal[10] = {0};
- int countNumbericVertical[10] = {0};
- int hasSameNumberInHorizontal = 0;
- int hasSameNumberInVertical = 0;
- for (int i = 0; i < n; i++) {
- // Set all counter to 0
- for (int k = 0; k < 10; k++) {
- countNumbericHorizontal[k] = 0;
- countNumbericVertical[k] = 0;
- }
- // Check Horizontal and Vertical
- for (int j = 0; j < n; j++) {
- for (int k = 0; k < n; k++) {
- if (k != j) {
- if (board[i][j] == board[i][k]) {
- countNumbericHorizontal[board[i][j]] += 1;
- }
- if (board[j][i] == board[k][i]) {
- countNumbericVertical[board[j][i]] += 1;
- }
- }
- // countNumbericHorizontal[board[i][j]] += 1;
- // countNumbericVertical[board[j][i]] += 1;
- }
- // board[i][j] to right
- // board[j][i] to bottom
- }
- // Check same number
- for (int k = 0; k < 10; k++) {
- if (countNumbericHorizontal[k] > 1) {
- hasSameNumberInHorizontal = 1;
- }
- if (countNumbericVertical[k] > 1) {
- hasSameNumberInVertical = 1;
- }
- }
- // printf("Horizontal: %d\n", hasSameNumberInHorizontal);
- // printf("Vertical: %d\n", hasSameNumberInVertical);
- }
- if (hasSameNumberInHorizontal || hasSameNumberInVertical) {
- printf("Nay\n");
- } else {
- printf("Yay\n");
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement