字符串倒序输出,C++

#include <iostream>
#include <string>
using namespace std;
int main() { 
 string word;
 cin >> word;
 char temp;
 int i, j;
 for (j = 0, i = word.size() - 1; j < i; --i, ++j) { 
  temp = word[i];
  word[i] = word[j];
  word[j] = temp;
 }
 cout << word << endl;
 system("pause");
 return 0;
}

《字符串倒序输出,C++》

    原文作者:一叶孤舟渡
    原文地址: https://blog.csdn.net/kangjielearning/article/details/106304752
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞