Advertisement
Guest User

Random

a guest
Feb 25th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <conio.h>
  4. #include <time.h>
  5. #include <cstdlib>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. string num[10]={"0","1","2","3","4","5","6","7","8","9"};
  11. string fnum;
  12. int ran, ran2, ran3, ran4;
  13.  
  14. int main()
  15. {
  16.     fstream nfile;
  17.     nfile.open("Numbers.txt", ios::out);
  18.     srand(time(NULL));
  19.     for(int i=0;i<=100;i++)
  20.     {
  21.     ran =rand()%10;
  22.     ran2=ran;
  23.     ran =rand()%10;
  24.     ran3=ran;
  25.     ran =rand()%10;
  26.     ran4=ran;
  27.     ran =rand()%10;
  28.     fnum=num[ran]+num[ran2]+num[ran3]+num[ran4];
  29.     cout<<fnum<<endl;
  30.     nfile<<fnum<<endl;
  31.     Sleep(1000);
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement