fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // zdefiniuj funkcję
  5. string szyfr(string s) {
  6. string t="";
  7. for (int i=0; i<s.size()-1; i+=2)
  8. t=t+s[i+1]+s[i];
  9. if (s.size() %2 != 0)
  10. t=t+s[s.size()-1];
  11. return t;
  12.  
  13. }
  14. int main() {
  15. cout<< szyfr("kotwica") <<endl;
  16. cout<< szyfr("szyfrowanie jest trudne") <<endl;
  17. // sprawdź działanie funkcji
  18. return 0;
  19. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
okwtcia
zsfyorawin eejtst urnde