PCLP2/lab06/01.cpp
Fándly Gergő 7adb051d16 chore: Lab06
2020-04-12 12:02:41 +03:00

37 lines
443 B
C++

#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;
}