candrei98

Cryptare string Cifrul lui Cezar

Dec 8th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main()
  6. {
  7.     int nr = 0, o=0;
  8.     char key, v[10];
  9.  
  10.     printf("Offset:");
  11.     scanf_s("%d", &o);
  12.     printf("\nPlainText:");
  13.  
  14.     for (int i = 0; i < 200; i++) {
  15.         key = _getch();
  16.         v[i] = key;
  17.         printf("%c", key);
  18.         nr++;
  19.         if (v[i] + o > 126)
  20.             break;
  21.         else if (v[0] == 32)
  22.             break;
  23.         else if (v[i] == 27)
  24.             break;
  25.         else if (v[i] == 13)
  26.             break;
  27.         else if (v[i] == 14 || v[i] == 15) {
  28.             key = _getch();
  29.             v[i] = key;
  30.         }
  31.  
  32.     }
  33.  
  34.     printf("\nOutput:\n");
  35.  
  36.     for (int i = 0; i < nr-1; i++) {
  37.         v[i] = v[i] + o;
  38.         printf("%c",v[i]);
  39.     }
  40.  
  41.     _getch();
  42.     exit(0);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment