Advertisement
dllbridge

Untitled

Mar 1st, 2023
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.37 KB | None | 0 0
  1.  
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <ctype.h>
  7. using namespace std;
  8.  
  9.  
  10. int                              n;
  11. int                      l =     0;
  12. bool                   ans = false;
  13.  
  14. int                 GetRandomnum();
  15.  
  16.  
  17.  
  18.  
  19. /////////////////////////////////////////////////////////////////////
  20. int main()                                                         //
  21. {
  22.  
  23.     srand(time(0) );
  24.  
  25.     cin >> n;
  26.     char *sz2 = new char[n];
  27.     cout <<"enter messages" << endl;
  28.    
  29.     cin >> sz2;
  30.            
  31.     char ABC[49] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_.,0123456789";        
  32.     char abc[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','.',',','0',
  33.             '1','2','3','4','5','6','7','8','9' };
  34.  
  35.  
  36.     for(int j = 0; j < n; j++)
  37.     {
  38.             ans = isupper(sz2[j]);
  39.            
  40.             if(ans == true)
  41.             {
  42.                 sz2[j] = ABC[GetRandomnum() + j];
  43.             }
  44.             else
  45.             {
  46.                 sz2[j] = abc[GetRandomnum() + j];
  47.             }
  48.     }
  49.    
  50.  
  51.     cout << sz2;
  52. }
  53.  
  54.  
  55.  
  56. ///////////////////////////////////////////////////////////////////////
  57. int GetRandomnum()                                                   //
  58. {
  59.  
  60.    
  61.  
  62.     int num = rand()%26 + 1;
  63.  
  64. return num;
  65. }
  66.  
  67.  
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement