Facebook
From Mungo Octupus, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 43
  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.  
  25.     for (it = random_numbers.begin(); it != random_numbers.end(); ++it)
  26.     {
  27.     std::cout << *it << '\n';
  28.     }
  29.     fstream plik( "plik.txt", ios::app );
  30.     if( plik.good() )
  31.     {
  32.         int a = *it
  33.         plik<<a<<endl;
  34.        
  35.        
  36.  
  37. }
  38. plik.close();
  39. }