GastonFontenla

GeneradorCasosMultiplicar

Nov 11th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <random>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. string randomString(mt19937 &random, uniform_int_distribution <char> &distribucion, int largoString)
  9. {
  10.     string s;
  11.  
  12.     for(int i=0; i<largoString; i++)
  13.         s += distribucion(random);
  14.  
  15.     while(s[0] == '0')
  16.         s[0] = distribucion(random);
  17.  
  18.     return s;
  19. }
  20.  
  21. int main()
  22. {
  23.     mt19937 random(time(0));
  24.     uniform_int_distribution <char> distribucion('0', '9');
  25.  
  26.     ofstream casos1("casosCorrectitud.txt");
  27.     casos1 << 10000 << endl; ///10000 casos para testear si multiplica bien
  28.     for(int i=0; i<10000; i++)
  29.     {
  30.         casos1 << randomString(random, distribucion, 6) << " ";
  31.         casos1 << randomString(random, distribucion, 6) << endl;
  32.     }
  33.  
  34.     casos1.close();
  35.  
  36.     ofstream casos2("casosGrandes.txt");
  37.     casos2 << 20 << endl;
  38.     for(int i=0; i<20; i++)
  39.     {
  40.         casos2 << randomString(random, distribucion, 10000) << " ";
  41.         casos2 << randomString(random, distribucion, 10000) << endl;
  42.     }
  43.  
  44.     casos2.close();
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment