Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ŚREDNIA ARYTMETYCZNA Z PLIKU
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- float a,suma=0, i=0, srednia=0;
- ifstream liczby("liczby.txt");
- while(!liczby.eof()){
- liczby>>a;
- suma=suma+a;
- i++;
- }
- liczby.close();
- srednia=suma/i;
- cout<<"srednia: "<<srednia<<endl;
- ofstream out("plik.txt");
- out<<"srednia: "<<srednia<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment