fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. const int shift=28;
  9. while(true)
  10. {
  11. cout<<"Wprowadz tekst: ";
  12. char tekst[100];
  13. if(!cin.get(tekst,sizeof(tekst))) break;
  14. for(int i=0;tekst[i];++i) tekst[i]=isalpha(tekst[i])?(toupper(tekst[i])-'A'+26+shift)%26+'A':tekst[i];
  15. cout<<"Zakodowany tekst: "<<tekst<<endl;
  16. for(int i=0;tekst[i];++i) tekst[i]=isalpha(tekst[i])?(toupper(tekst[i])-'A'+26-shift)%26+'A':tekst[i];
  17. cout<<"Odkodowany tekst: "<<tekst<<endl;
  18. }
  19. }
Success #stdin #stdout 0s 3300KB
stdin
Ala ma kota
stdout
Wprowadz tekst: Zakodowany tekst: CNC OC MQVC
Odkodowany tekst: ALA MA KOTA
Wprowadz tekst: