fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string encrypted, decrypted;
  8. while (getline(cin,encrypted))
  9. {
  10. int j = 0;
  11. int n = 0;
  12. if (encrypted.size() == 1)
  13. {
  14. encrypted+=' ';
  15. cout << encrypted << endl;
  16. encrypted.clear();
  17. continue;
  18. }
  19. while (encrypted[n] != ' ')
  20. {
  21. n++;
  22. j++;
  23. }
  24. for (int i = 0,t=0;i < n;i++)
  25. {
  26. decrypted += encrypted[i];
  27. t++;
  28. if ((encrypted[j] == ' ') && (encrypted[j + 1] == ' ')&&(j<encrypted.length()-1))
  29. {
  30. decrypted += ' ';
  31. t++;
  32. j += 2;
  33. continue;
  34. }
  35. else if (encrypted[j] == ' ') { j++; }
  36. while ((encrypted[j] != ' ')&&(j<encrypted.length()))
  37. {
  38. decrypted += encrypted[j];
  39. t++;
  40. j++;
  41. }
  42. decrypted += ' ';
  43. }
  44. cout << decrypted << endl;
  45. decrypted.clear();
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0s 4556KB
stdin
AMK LA A OTA
BIL OLEK  OLEK
EWWLPRK NIGMA  ERSJI IGHT O AZ OLEJNY
stdout
ALA MA KOTA 
BOLEK I LOLEK 
ENIGMA W WERSJI LIGHT PO RAZ KOLEJNY