Advertisement
PiotrJurek

Zad 1

May 30th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     ofstream plik("plik.txt");
  9.     int x;
  10.     srand(time(NULL));
  11.     if(plik.is_open())
  12.     {
  13.         for(int i=0; i<10; i++)
  14.         {
  15.             x = rand()%30+1;
  16.             plik << x;
  17.             plik << endl;
  18.         }
  19.         cout << "Zapis udany.";
  20.     }
  21.     else
  22.     {
  23.         cout << "Blad zapisu. Konczenie programu.";
  24.     }
  25.  
  26.     plik.close();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement