Advertisement
Ritam_C

Uri 1064

Jan 8th, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     double a[6], s = 0;
  8.     int c = 0;
  9.     for(int i = 0; i < 6; i++){
  10.         cin >> a[i];
  11.         if(a[i] > 0){
  12.             c++;
  13.             s += a[i];
  14.         }
  15.     }
  16.    
  17.     cout << c << " valores positivos\n";
  18.     cout << fixed << setprecision(1) << s/c << "\n";
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement