Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <fstream>
- using namespace std;
- int main()
- {
- int maxi=0;
- int liczba;
- srand(time(NULL));
- ofstream zapis("plik.txt");
- ifstream odczyt("plik.txt");
- if(zapis.is_open())
- {
- for(int i=0; i<10; i++)
- {
- zapis << rand()%1001+1000 << endl;
- }
- }
- else
- {
- cout << "Zapis nieudany.";
- }
- if(odczyt.is_open())
- {
- for(int i=0; i<10; i++)
- {
- odczyt >> liczba;
- maxi = liczba>maxi ? liczba : maxi;
- }
- }
- else
- {
- cout << "Odczyt nieudany.";
- }
- cout << "Najwieksza liczba w pliku to: " << maxi << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement