Advertisement
Guest User

set4 probl 7

a guest
Jan 25th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>;
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int v[25];
  9.     int c, n;
  10.     int sum, i;
  11.     float media;
  12.  
  13.     cout << "Introduceti numarul de zile "; cin >> n;
  14.     cout << "Introduceti temperatura din aceste zile " << endl;
  15.     for (c = 0; c < n; c++) {
  16.         cout << "v[" << c << "]= "; cin >> v[c];
  17.     }
  18.     sum = 0;
  19.     i = 0;
  20.     media = 0;
  21.     for (c = 0; c < n; c++) {
  22.         if (v[c] > 0) {
  23.             sum = sum + v[c];
  24.             i++;
  25.  
  26.         }
  27.     }
  28.     media = sum / i;
  29.     cout<<"temperatura medie pozitiva este: " << media<<endl;
  30.  
  31.     sum = 0;
  32.     i = 0;
  33.     media = 0;
  34.     for (c = 0; c < n; c++) {
  35.         if (v[c] < 0) {
  36.             sum = sum + v[c];
  37.             i++;
  38.  
  39.         }
  40.     }
  41.     media = sum / i;
  42.     cout << "temperatura medie negativa este: " << media << endl;
  43.  
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement