Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int m;
- int n;
- cin>>m;
- cin>>n;
- int matrica[m][n];
- int zbir=0;
- int zbir2=0;
- int krajenzbir=0;
- for(int i=0; i<m; i+=1){
- for(int i1=0; i1<n; i1+=1){
- cin>>matrica[i][i1];
- }
- }
- for(int k=0; k<m; k+=1){
- for(int x=0; x<n/2; x+=1){
- zbir+=matrica[k][x];
- }
- for(int y=n/2; y<n; y+=1){
- zbir2+=matrica[k][y];
- }
- if(zbir>zbir2){
- krajenzbir=zbir-zbir2;
- }
- if(zbir<zbir2){
- krajenzbir=zbir2-zbir;
- }
- if(n%2!=0){
- matrica[k][n/2]=krajenzbir;
- }
- if(n%2==0){
- matrica[k][n/2]=krajenzbir;
- matrica[k][n/2-1]=krajenzbir;
- }
- zbir=0;
- zbir2=0;
- krajenzbir=0;
- }
- for(int j=0; j<m; j+=1){
- for(int l=0; l<n; l+=1){
- cout<<matrica[j][l]<<" ";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement