Advertisement
Pafnytiu

массивы 1.2

Nov 10th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<fstream>
  4. using namespace std;
  5. int main()
  6. {
  7.     ifstream in("input.txt");
  8.     ofstream out("output.txt");
  9.     int a[100];
  10.     int n,m=0;
  11.     float sum=0;
  12.     in >> n;
  13.     for (int i = 0; i < n;i++)
  14.     {
  15.         {in >> a[i];
  16.         if (a[i] < 0) {
  17.  
  18.             sum += a[i];
  19.             m++;
  20.         }
  21.         }
  22.        
  23.     }
  24.     sum /= m;
  25.     out << sum<< endl;
  26.     in.close();
  27.     out.close();
  28.     system("pause");
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement