fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. #define MAX_SIZE 1024
  5.  
  6. using namespace std;
  7.  
  8. int main(void)
  9. {
  10. char line[MAX_SIZE];
  11. while (cin.getline(line, MAX_SIZE))
  12. {
  13. // 根據空白切割字串
  14. char *token = strtok(line, " ");
  15. while (token)
  16. {
  17. // 顛倒印出字串
  18. int length = strlen(token);
  19. for (int i = length - 1; i >= 0; i--)
  20. {
  21. cout << token[i];
  22. }
  23.  
  24. token = strtok(NULL, " ");
  25. if (token) { cout << " "; }
  26. }
  27.  
  28. cout << endl;
  29. }
  30.  
  31. #ifndef ONLINE_JUDGE
  32. system("pause");
  33. #endif
  34.  
  35. return 0;
  36. }
  37.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty