Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int i, x, n;
  7. char str[100];
  8. char str2[100];
  9.  
  10. cout << "tell me why you got something to hide:\t";
  11. cin >> str;
  12. cout<< "tell me why you got the key here: ";
  13. cin>>n;
  14.  
  15. cout << "\nchoose wise:\n";
  16. cout << "1 = zaszyfrowanie.\n";
  17. cout << "2 = odszyfrowanie.\n";
  18.  
  19. cin >> x;
  20.  
  21. switch(x)
  22. {
  23.  
  24. case 1:
  25.  
  26. for(i = 0; (i < 100 && str[i] != '\0'); i++)
  27. str[i] = str[i] + n;
  28.  
  29. cout << "\nZaszyfrowanie: " << str << endl;
  30. break;
  31.  
  32.  
  33. case 2:
  34.  
  35. for(i = 0; (i < 100 && str[i] != '\0'); i++)
  36. str[i] = str[i] - n;
  37.  
  38. cout << "\nOdszyfrowanie: " << str << endl;
  39. break;
  40.  
  41. default:
  42. cout << "\nZle dane !!!\n";
  43.  
  44. }
  45. return x;
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement