The_road_to_learn_C++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
340 B

11 months ago
  1. #include <iostream>
  2. int main()
  3. {
  4. using namespace std;
  5. cout << "Enter a word: ";
  6. string word;
  7. cin >> word;
  8. char temp;
  9. int i, j;
  10. for (j = 0, i = word.size() - 1; j < i; --i, ++j)
  11. {
  12. temp = word[i];
  13. word[i] = word[j];
  14. word[j] = temp;
  15. }
  16. cout << word << "\nDone\n";
  17. return 0;
  18. }