Advertisement
Lukasz_Miskiewicz

operacje na plikach zad 4

May 24th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <fstream>
  5. using namespace std;
  6. int a,b,c;
  7.  
  8. int main()
  9. {
  10.     ofstream zapis_pliku ("plik.txt");
  11.     for(int i=0;i<10;i++)
  12.     {
  13.         zapis_pliku<<1000+rand()%(1001)<<endl;
  14.     }
  15.     c=0;
  16.     ifstream odczyt_pliku ("plik.txt"); //odczyt z pliku
  17.     for(int i=0;i<10;i++)
  18.     {
  19.         odczyt_pliku>>a;
  20.         if(c<a)
  21.         {
  22.             c=a;
  23.         }}
  24.     cout<<"najwieksza wartosc to ";
  25.     cout<<c;
  26.  return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement