Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <conio.h>      //_getch();
  4. #include <Windows.h>
  5. #include <ctime>        //time_t, struct tm, localtime_s, strftime
  6. using namespace std;
  7.  
  8. char* tag(){
  9.     //char *random1 = new char[];
  10.     //random1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  11.     //  size_t size1 = (sizeof random1 / sizeof random1[0]);
  12.  
  13.     //char *random2 = new char[];
  14.     //random2 = "0123456789";
  15.     //  size_t size2 = (sizeof random2 / sizeof random2[0]);
  16.  
  17.     char random1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  18.     char random2[] = "0123456789";
  19.     size_t size1 = (sizeof random1 / sizeof random1[0]-1);
  20.     size_t size2 = (sizeof random2 / sizeof random2[0]-1);
  21.  
  22.         int r1 = 0;
  23.         int r2 = 0;
  24.  
  25.     char ra1[5] = "";
  26.     char ra2[4] = "";
  27.     char s[9] = "";
  28.  
  29.     for(int i = 0; i<4; ++i){  
  30.         r1 = rand() % size1;
  31.         ra1[i] = random1[r1];
  32.     }
  33.  
  34.     for (int i = 0; i < 4; ++i){
  35.         r2 = rand() % size2;
  36.         ra2[i] = random2[r2];
  37.     }
  38.  
  39.     sprintf_s(s,"%c%c%c%c-%c%c%c",ra1[0],ra1[1],ra1[2],ra1[3],ra2[0],ra2[1],ra2[2]);
  40.     cout << s << endl;
  41.     _getch();
  42.  
  43.     //delete [] random1;
  44.     //delete [] random2;
  45.  
  46.     return s;
  47. }
  48.  
  49. const time_t ctt = time(0);
  50.  
  51. int main(){
  52.     cout << tag();
  53.     _getch();
  54. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement