Advertisement
dllbridge

Untitled

Aug 7th, 2024
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.93 KB | None | 0 0
  1.  
  2.  
  3. #include  <stdio.h>
  4. #include <string.h>
  5.  
  6. char sz[59]="SONY Pictures";
  7.  
  8. void  encryption(char *p);
  9. void de_cryption(char *p);  
  10.  
  11. int n = 12;                                     // Ключ шифрования
  12.  
  13. //////////////////////////////////////////////////
  14. int main()
  15. {
  16.     encryption(sz);  
  17.      
  18.     printf("%s \n", sz);  
  19.    
  20.     de_cryption(sz);  
  21.      
  22.     printf("%s \n", sz);      
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. //////////////////////////////////////////////////
  34. void de_cryption(char *p)                        // = Y
  35. {
  36.        
  37.    
  38.        
  39.     int nLen = strlen(p);
  40.    
  41.     for(int i = 0; i < nLen; i++)
  42.     {
  43.    
  44.        p[i] = p[i] - n;  
  45.     }
  46.            
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. //////////////////////////////////////////////////
  61. void encryption(char *p)                        // = Y
  62. {
  63.        
  64.  
  65.        
  66.     int nLen = strlen(p);
  67.    
  68.     for(int i = 0; i < nLen; i++)
  69.     {
  70.    
  71.        p[i] = p[i] + n;  
  72.     }
  73.            
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  //   printf("%c \n", sz[2]);  
  82.  
  83.  
  84.  
  85. /*
  86. #include<stdio.h>
  87. char sz[5]="SONY";
  88.  
  89. //////////////////////////////////////////////////
  90. void foo(char *p)                               // = Y
  91. {
  92.        
  93.        
  94.      char *p1 = p-1;                            // = N
  95.        
  96.      char c = *p;                               // = Y  
  97.      
  98.      *p = *p1;  
  99.      
  100.      *p1 = c;  
  101. }
  102.  
  103.  
  104. //////////////////////////////////////////////////
  105. int main()
  106. {
  107.     char *p = &sz[3];
  108.    
  109.     foo(p);
  110.    
  111.  
  112.     printf("%s \n",sz);
  113.        
  114. }      
  115.  
  116.  
  117.  
  118.  
  119. */
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. /*
  129.  
  130. #include<stdio.h>
  131. char sz[5]="SONY";
  132.  
  133. //////////////////////////////////////////////////
  134. void foo(char *p)
  135. {
  136.      char c = *p;
  137.      
  138.      *p = *(p-1);  
  139.      
  140.      *(p-1) = c;  
  141. }
  142.  
  143.  
  144. //////////////////////////////////////////////////
  145. int main()
  146. {
  147.     char *p=&sz[3];
  148.    
  149.     foo(p);
  150.    
  151.  
  152.     printf("%s \n",sz);
  153.        
  154. }      
  155.  
  156.  
  157. */
  158.  
  159.  
  160.  
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement