Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- float a[51][50],s[50]; /// Matricea si sumele pe coloane
- for(int i=0;i<n;++i) /// Citesc matricea
- for(int j=0;j<n;++j)
- cin>>a[i][j];
- for(int j=0;j<n;++j) /// Calculez suma elementelor pe coloane
- for(int i=0;i<n;++i)
- s[j]+=a[i][j];
- for(int i=0;i<n/2;++i) /// Afisez prmele n/2 linii
- {
- for(int j=0;j<n;++j)
- cout<<a[i][j]<<' ';
- cout<<'\n';
- }
- for(int j=0;j<n;++j) /// Afisez linia adaugata cu mediile aritmetice
- cout<<s[j]/n<<' ';
- cout<<'\n';
- for(int i=n/2;i<n;++i) /// Afisez ultimele n/2 linii
- {
- for(int j=0;j<n;++j)
- cout<<a[i][j]<<' ';
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement