Advertisement
PatrickSwayze

Untitled

Oct 30th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout<<"Witaj w programie, ktory liczy stosunek sumy elementów wewnętrznych do zewnętrznych w macierzy kwadratowej."<<endl;
  8.     cout<<"Wprowadz wymiary wiersza oraz kolumny w postaci liczb rzeczywistych: "<<endl;
  9.     float x[10][10];
  10.     float m,n;
  11.     cin>>n>>m;
  12.     for (int i=0;i<n;i++)
  13.     {
  14.         for (int j=0;j<m;j++)
  15.         {
  16.             cout<<"Wprowadz kolejno wartosc wiersza oraz wartosc kolumny: "<<endl;
  17.             cin>>x[i][j];
  18.         }
  19.     }
  20.  
  21.  
  22.     float elwew=0;
  23.     float sumaelwew=0;
  24.     for (int i=1;i<n-1;i++)
  25.     {
  26.         for (int j=1;j<m-1;j++)
  27.         {
  28.             elwew=elwew+x[i][j];
  29.         }
  30.     }
  31.     cout<<"Suma elementow wewnetrznych wynosi: "<<elwew<<endl;
  32.  
  33.  
  34.     float allel=0;
  35.     for (int i=0;i<n;i++)
  36.     {
  37.         for (int j=0;j<m;j++)
  38.         {
  39.             allel=allel+x[i][j];
  40.         }
  41.     }
  42.     cout<<"Suma elementow wszystkich wynosi: "<<allel<<endl;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement