Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int n, m;
- scanf("%d%d", &n, &m);
- int A[n][n], B[m][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- scanf("%d", &A[i][j]);
- }
- }
- for(int i = 0; i < m; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &B[i][j]);
- }
- }
- int zbir_pod_glavna_A = 0, zbir_pod_glavna_B = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- if(j < i) {
- zbir_pod_glavna_A += A[i][j];
- }
- }
- }
- for(int i = 0; i < m; i++) {
- for(int j = 0; j < m; j++) {
- if(j < i) {
- zbir_pod_glavna_B += B[i][j];
- }
- }
- }
- int pomal_od_n_i_m = 0;
- if(n < m) {
- pomal_od_n_i_m = n;
- }
- else {
- pomal_od_n_i_m = m;
- }
- for(int i = 0; i < pomal_od_n_i_m; i++) {
- if(A[i][i] == B[i][i]) {
- A[i][i] = zbir_pod_glavna_A;
- B[i][i] = zbir_pod_glavna_B;
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- printf("%d ", A[i][j]);
- }
- printf("\n");
- }
- for(int i = 0; i < m; i++) {
- for(int j =0 ; j < m; j++) {
- printf("%d ", B[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement