Advertisement
Guest User

Vidurkis

a guest
Nov 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<fstream>
  2. #include<iomanip>
  3. using namespace std;
  4.  
  5. double v(int a,int b,int c,int d,int e)
  6. {
  7.     return (a + b + c + d + e)  / 5.0;
  8. }
  9.  
  10. int main()
  11. {
  12.     double vid;
  13.     int a, b, c, d, e;
  14.  
  15.     ifstream fd("Pazymiai.txt");
  16.     ofstream fr("Vidurkiai.txt");
  17.  
  18.     for ( int i = 0; i < 5; i++) {
  19.         fd >> a >> b >> c >> d >> e;
  20.         vid = v(a, b, c, d, e);
  21.         fr << fixed << setprecision(2) << vid << endl;
  22.     }
  23.  
  24.     fd.close();
  25.     fr.close();
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement