Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define SIZE 5
- int main()
- {
- int tab[SIZE][SIZE];
- int max[SIZE][4];
- printf("Podaj elementy: \n");
- for(int i = 0;i<SIZE;i++)
- {
- for(int j=0;j<SIZE;j++)
- {
- if(!scanf("%d",&tab[i][j]))
- {
- printf("Incorrect input");
- return 1;
- }
- }
- }
- int max_val = tab[0][0] + tab[0][1];
- for(int i=0;i<SIZE;i++)
- {
- for(int j=0;j<SIZE;j++)
- {
- for(int k=0;k<SIZE;k++)
- {
- for(int l=0;l<SIZE;l++)
- {
- if(tab[i][j]+tab[k][l] > max_val && !(i==k && j==l)&& SIZE*i+j<SIZE*k+l )max_val = tab[i][j]+tab[k][l];
- }
- }
- }
- }
- int count = 0;
- for(int i=0;i<SIZE;i++)
- {
- for(int j=0;j<SIZE;j++)
- {
- for(int k=0;k<SIZE;k++)
- {
- for(int l=0;l<SIZE;l++)
- {
- int x = tab[i][j]+tab[k][l];
- //int x = 0;
- if(x == max_val && !(i==k && j==l)&& SIZE*i+j<SIZE*k+l)
- {
- max[count][0] = i;
- max[count][1] = j;
- max[count][2] = k;
- max[count][3] = l;
- count++;
- }
- }
- }
- }
- }
- printf("%d %d\n",max_val,count);
- for(int i=0;i<count;i++)
- {
- printf("%d %d %d %d\n",max[i][0],max[i][1],max[i][2],max[i][3]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement