Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main (){
- int n,m;
- int a,b;
- scanf("%d%d",&n,&m);
- scanf("%d%d",&a,&b);
- if(a !=n){
- printf("ne e ist brojot na redici");
- return 1;
- }
- int mat[n][m];
- int mat2[a][b];
- for(int i=0;i<n;i++){
- for (int j=0;j<m;j++){
- scanf("%d",&mat[i][j]);
- }
- }
- for(int i=0;i<a;i++){
- for (int j=0;j<b;j++){
- scanf("%d",&mat2[i][j]);
- }
- }
- int brojac=0;
- for(int j=0;j<m;j++){
- int zbir=mat[0][j]+mat[n-1][j];
- // interator za vtorata mat e pom
- for(int pom=0;pom<b;pom++){
- int zbir2=mat2[0][pom]+mat2[a-1][pom];
- printf("%d %d %d %d\n",j, pom, zbir, zbir2);
- if(zbir==zbir2){
- for (int i = 0; i < n; i++) {
- int temp = mat[i][j];
- mat[i][j] = mat2[i][pom];
- mat2[i][pom] = temp;
- }
- printf("%d %d\n", j, pom);
- brojac++;
- break;
- }
- }
- }
- printf("brojot na zameni %d\n",brojac);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- printf("\n");
- for (int i = 0; i < a; i++) {
- for (int j = 0; j < b; j++) {
- printf("%d ", mat2[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 5 5
- 5 6
- 10 2 1 1 1
- 4 7 3 2 0
- 5 2 5 7 2
- 6 5 4 18 2
- 2 16 15 9 10
- 1 4 9 3 2 2
- 4 17 6 12 10 6
- 5 0 15 0 8 5
- 6 7 7 8 1 10
- 2 8 1 9 10 3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement