candrei98

Untitled

Dec 8th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. /*#include <iostream>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <vector>
  7. #include <string>
  8.  
  9. using namespace std;
  10.  
  11. int n ;
  12.  
  13. void alfabet_initial()
  14. {
  15.     for (char i = 32; i <= 126; i++)
  16.     {
  17.         printf("%c ", i);
  18.     }
  19. }
  20.  
  21. void alfabet_defazat() {
  22.  
  23.     printf("\n");
  24.     printf("Cu cate caractere vreti sa fie defazat: ");
  25.     scanf_s("%d", &n);
  26.     printf("\n");
  27.  
  28.     for (char i = 32; i <= 126; i++)
  29.     {
  30.         printf("%c ", i+n);
  31.     }
  32.  
  33. }
  34.  
  35. void cryptare() {
  36.  
  37.     char name[30];
  38.     printf("Enter name: ");
  39.     fgets(name, sizeof(name), stdin);    // read string
  40.     printf("Name: ");
  41.     puts(name);    // display string
  42. }
  43.  
  44. void main(void)
  45. {
  46.     system("cls");
  47.  
  48.     char n, i, x[50];
  49.  
  50.     alfabet_initial();
  51.     alfabet_defazat();
  52.  
  53.     _getch();
  54. }
  55.  
  56. */
  57.  
  58. #include <conio.h>
  59. #include <stdio.h>
  60.  
  61. int main()
  62. {
  63.     int nr = 0, o=0;
  64.     char key, v[10];
  65.  
  66.     printf("Offset:");
  67.     scanf_s("%d", &o);
  68.     printf("\nPlainText:");
  69.  
  70.     for (int i = 0; i < 200; i++) {
  71.         key = _getch();
  72.         v[i] = key;
  73.         printf("%c", key);
  74.         nr++;
  75.         if (v[i] + o > 126)
  76.             break;
  77.         else if (v[0] == 32)
  78.             break;
  79.         else if (v[i] == 27)
  80.             break;
  81.         else if (v[i] == 13)
  82.             break;
  83.         else if (v[i] == 14 || v[i] == 15) {
  84.             key = _getch();
  85.             v[i] = key;
  86.         }
  87.  
  88.     }
  89.  
  90.     printf("\nOutput:\n");
  91.  
  92.     for (int i = 0; i < nr-1; i++) {
  93.         v[i] = v[i] + o;
  94.         printf("%c",v[i]);
  95.     }
  96.  
  97.     _getch();
  98. }
Advertisement
Add Comment
Please, Sign In to add comment