Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int a[100][100], b[100][100], m, n, i, j, k, l, red, redmax;
- int c[100][100];
- double zbir1, zbir2, br1, br2;
- scanf("%d%d", &m, &n);
- for(i=0; i<m; i++){
- for(j=0; j<n; j++)
- scanf("%d", &a[i][j]);
- }
- scanf("%d%d", &k, &l);
- for(i=0; i<k; i++){
- for(j=0; j<l; j++)
- scanf("%d", &b[i][j]);
- }
- if(n!=l){
- printf("Nemaat ist br na koloni\n");
- return 0;
- }
- if(m<k){
- red=m;
- redmax=k;
- }
- else {
- red=k;
- redmax=m;
- }
- for(i=0; i<red; i++){
- zbir1=0;
- zbir2=0;
- br1=0;
- br2=0;
- for(j=0; j<n; j++){
- zbir1+=a[i][j];
- br1++;
- }
- for(j=0; j<l; j++){
- zbir2+=b[i][j];
- br2++;
- }
- for(j=0; j<n; j++){
- if((zbir1/br1)>(zbir2/br2))
- c[i][j]=a[i][j];
- else
- c[i][j]=b[i][j];
- }
- }
- for(i=red; i<redmax; i++){
- for(j=0; j<n; j++){
- c[i][j]=a[i][j];
- }
- }
- for(i=0; i<redmax; i++){
- for(j=0; j<n; j++)
- printf("%d ", c[i][j]);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement