Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int matrix[3][3] = {
- {1, 2, 3},
- {4, 5, 6},
- {7, 8, 9}};
- int x = 0, y = 0, hasRepeated = 0;
- // Para cada valor vai ver se existe repetido na matriz
- while (1)
- {
- // Percorre a matriz
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- if (i != x || j != y)
- {
- if (matrix[i][j] == matrix[x][y])
- {
- hasRepeated = 1;
- }
- }
- }
- }
- y++;
- if (y == 3)
- {
- x++;
- y = 0;
- if (x == 3)
- {
- break;
- }
- }
- }
- if (hasRepeated == 1)
- printf("Tem numeros repetidos\n");
- else
- printf("Nao tem numeros repetidos\n");
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement