Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 500
- int main()
- {
- int a[MAX][MAX],n,m,niza[3], b[MAX][MAX], k, l;
- scanf("%d%d",&n,&m);
- for (int i=0; i<n; i++){
- for(int j=0; j<m;j++)
- {
- scanf("%d",&a[i][j]);
- }
- }
- scanf("%d%d", &k, &l);
- for(int i = 0; i < k; i++) {
- for(int j = 0; j < l; j++) {
- scanf("%d", &b[i][j]);
- }
- }
- if(m != l) {
- printf("Nemaat ist broj na koloni, ne moze da se zavrsi zadacata");
- return 0;
- }
- int r[MAX][MAX];
- int li = 0;
- for(int i = 0; i < n; i++) {
- int zbir1 = 0;
- int zbir2 = 0;
- if(i >= k) {
- li = i;
- break;
- }
- for(int j = 0; j < m; j++) {
- zbir1 += a[i][j];
- zbir2 += b[i][j];
- }
- if(zbir1 / m > zbir2 / l) {
- for(int j = 0; j < m; j++) {
- r[i][j] = a[i][j];
- }
- }
- else {
- for(int j = 0; j < m; j++) {
- r[i][j] = b[i][j];
- }
- }
- }
- for(int i = li; i < n; i++) {
- for(int j = 0; j < m; j++) {
- r[i][j] = a[i][j];
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- printf("%d ", r[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 5 4
- 1 2 7 3
- 2 2 4 0
- 5 6 0 1
- 1 2 3 4
- 3 2 0 12
- 3 4
- 1 2 3 0
- 5 6 0 7
- -1 -2 -3 12
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement