PCLP2/lab06/01.cpp

37 lines
443 B
C++
Raw Normal View History

2020-04-12 09:02:41 +00:00
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
int main(){
ios::sync_with_stdio(false);
fstream f;
f.open("examene.txt", ios_base::in);
if(!f.is_open()){
cout<<"Error: file does not exist";
return 1;
}
int sum=0;
for(int i=0; i<6; i++){
int buff;
f>>buff;
sum+=buff;
}
f.close();
f.open("media.txt", ios_base::out);
double avg = (double)sum / 6;
f<<avg;
f.close();
return 0;
}