37 lines
443 B
C++
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;
|
||
|
}
|