Facebook
From Smelly Bushbaby, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 40
  1. #include <random>
  2. #include <iostream>
  3. #include <set>
  4. #include <fstream>
  5. #include <stdlib.h>
  6. #include <ctime>
  7. #include <conio.h>
  8. #include <iomanip>
  9.  
  10. using namespace std;
  11. int main()
  12. {
  13.     std::random_device rd;
  14.     std::mt19937 gen(rd());
  15.     std::uniform_int_distribution<> dist(100000, 99999999);
  16.  
  17.     std::set<int> random_numbers;
  18.  
  19.     size_t how_many = 10;
  20.     while (random_numbers.size() < how_many)
  21.         random_numbers.emplace(dist(gen));
  22.  
  23.     std::set<int>::iterator it;
  24.     fstream plik( "plik.txt", ios::app );
  25.     for (it = random_numbers.begin(); it != random_numbers.end(); ++it)
  26.     {
  27.     if( plik.good() )
  28.     {
  29.         int a = *it;
  30.         plik<<a<<endl;
  31.        
  32.        
  33.  
  34.    }
  35.     std::cout << *it << '\n';
  36.     }
  37.    
  38.    
  39. plik.close();
  40. }