Haval1

find av for lower traingle diameter

Apr 29th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int i,j,a[3][3];
  6.     //input array
  7.     for(i=0;i<=2;i++)
  8.     {
  9.         for(j=0;j<=2;j++)
  10.         {
  11.             cout<<"["<<i<<"]["<<j<<"]";
  12.             cin>>a[i][j];
  13.         }
  14.     }
  15.     //output array
  16.     for(i=0;i<=2;i++)
  17.     {
  18.         for(j=0;j<=2;j++)
  19.         {
  20.             cout<<a[i][j]<<"\t";
  21.         }
  22.         cout<<endl<<endl;
  23.     }
  24.     //procces find av for lower traingle diameter
  25.     int n=0,x=0,sum=0;
  26.     for(i=0;i<=2;i++)
  27.     {
  28.         for(j=0;j<=n;j++)
  29.         {
  30.             sum+=a[i][j];
  31.             x++;
  32.         }
  33.         n++;
  34.     }
  35.     float av=sum/x;
  36.     cout<<"Av = "<<av;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment