fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. char randChar()
  7. {
  8. static char pool[]="ABCDEFGHIJKLMNOPRSTUWXYZ";
  9. return pool[rand()%(sizeof(pool)-1)];
  10. }
  11.  
  12. char randDigit()
  13. {
  14. static char pool[]="0123456789";
  15. return pool[rand()%(sizeof(pool)-1)];
  16. }
  17.  
  18. string kodowanie()
  19. {
  20. return string {{ randChar(),randChar(),randDigit(),randDigit() }};
  21. }
  22.  
  23. int main()
  24. {
  25. srand(time(0));
  26. cout<<kodowanie()<<endl;
  27. return 0;
  28. }
Success #stdin #stdout 0s 4752KB
stdin
Standard input is empty
stdout
KB42