Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define size 6
- void main(void) {
- int M[size][size];
- int i, j, a, flag, ind;
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- do {
- do {
- rewind(stdin);
- printf("Enter element with index [%d|%d]: ", i + 1, j + 1, "\n");
- ind = scanf_s("%d", &a);
- if (ind != 1) {
- printf("Incorrect input!!!\n");
- }
- } while (ind != 1);
- if ((a > 100) || (a < -100))
- {
- printf("Enter the number, which is higher than -100 and lower than 100");
- flag = 1;
- }
- else {
- flag = 0;
- }
- } while (flag == 1);
- M[i][j] = a;
- }
- }
- printf("Your matrix: \n");
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- printf(" %d", M[i][j]);
- }
- printf("\n");
- }
- int num = M[0][0];
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- if (M[i][j] >= num) {
- num = M[i][j];
- }
- }
- }
- printf("The biggest number is %d\n", num);
- printf("Indexes of the biggest elements from the matrix:\n");
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- if (M[i][j] == num) {
- printf("[%d|%d]\n", i + 1, j + 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement