fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. bool MakeHoge(std::string Str){
  5. int SP = 0;
  6. for (std::size_t i = 0; i+SP < Str.size(); i++){
  7. if (Str[i + SP] == ' ')SP++;
  8. if ((i) % 2 == 0)std::cout << Str[i + SP] << ' ';
  9. }
  10. std::cout << std::endl;
  11. SP = 0;
  12. for (std::size_t i = 0; i+SP < Str.size(); i++){
  13. if (Str[i + SP] == ' ')SP++;
  14. if ((i) % 2 == 1)std::cout << Str[i + SP] << ' ';
  15. }
  16. std::cout << std::endl;
  17. return true;
  18. }
  19.  
  20. int main(){
  21. std::string Str1= "123456789";
  22. std::string Str2 = "The earth turns around the sun.";
  23. std::string Str3 = "wa wa wa w w .";
  24.  
  25. MakeHoge(Str1);
  26. MakeHoge(Str2);
  27. MakeHoge(Str3);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1 3 5 7 9 
2 4 6 8 
T e a t t r s r u d h s n 
h e r h u n a o n t e u . 
w w w w . 
a a a w