Advertisement
Lisaveta777

supereasy2

Dec 22nd, 2019
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <math.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     setlocale(LC_ALL, "RUS");
  12.     int a[4][4]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,-4};
  13.    
  14.     double sr = 0, k = 0;
  15.    
  16.     for (int i = 0; i < 4; i = i + 1)
  17.         for (int j = 0; j < 4; j = j + 1) {
  18.             if (i + j >= 4 && a[i][j] < 0)
  19.                 sr = sr + a[i][j], k = k + 1,cout<<"NEVER GETS HERE ";
  20.                    
  21.             }
  22.                
  23.     cout << "sr before=" << sr << endl;
  24.     cout << "k berofe=" << k << endl;
  25.            
  26.     sr = sr / k;
  27.     cout << "sr=" << sr << endl;
  28.     cout << "k=" << k << endl;
  29.    
  30.     int i=1;
  31.     double p = 1;
  32.     for (int j = 0; j < 4; j++) {//why changed to j=j+1?
  33.             p = p * (cos(fabs(a[1][j]) + 3 * j));
  34.         }
  35.     cout << "p=" << p << endl;
  36.    
  37.     double s,c[4];
  38.     for (i = 0; i < 4; i++)
  39.         {
  40.             s = 0;
  41.             for (int j = 0; j < 4; j++)
  42.                 s = s + a[i][j];
  43.             c[i] = s;
  44.             cout << setw(10) << "c[i]" <<c[i]<< endl;
  45.                
  46.         }
  47.     return 0;
  48.  
  49.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement