#include //头文件,用于输入输出 #include //头文件,用于字符串处理 using namespace std; //命名空间 int main() //主函数 { string str; //定义字符串变量 getline(cin,str); //输入一行字符串 for(int i = str.size()-1;i>=0;i--) //for循环,从字符串末尾开始遍历 cout << str[i]; //输出逆序后的字符串 }

给下面代码加上备注#include iostream#include stringusing namespace std;int main string str; getlinecinstr; forint i = strsize-1;i=0;i-- cout stri;

原文地址: https://www.cveoy.top/t/topic/eqUK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录