Guest User

Untitled

a guest
Jan 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. your
  2. text
  3. would
  4. be
  5. entered
  6. like
  7. this
  8.  
  9. youway exttay ouldway ebay enteredway ikelay histay
  10.  
  11. your text would be entered like this
  12.  
  13. std::string in;
  14. while (std::cin >> in)
  15. std::cout << piglatin(in) << char(std::cin.get());
  16.  
  17. #include <cctype>
  18. char look_for_nl(std::istream& is) {
  19. for (char d = is.get(); is; d = is.get()) {
  20. if (d == 'n') return d;
  21. if (!isspace(d)) {
  22. is.putback(d);
  23. return ' ';
  24. }
  25. }
  26. // We got an eof and there was no NL character. We'll pretend we saw one
  27. return 'n';
  28. }
  29.  
  30. std::string in;
  31. while (std::cin >> in)
  32. std::cout << piglatin(in) << look_for_nl(std::cin);
Add Comment
Please, Sign In to add comment