题目链接:http://ac.jobdu.com/problem.php?pid=1055
题目分析:
简单的数组逆置,输入string字符串,使用for循环逆序输出。
源代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
while (cin>>s)
{
for (int i = s.length() - 1; i >= 0; i--)
{
cout<<s[i];
}
cout<<endl;
}
}
本文介绍了一个简单的字符串逆置算法实现。通过C++语言演示了如何读取一个字符串,并使用for循环从最后一个字符开始逐个输出,从而达到逆置字符串的效果。
1723

被折叠的 条评论
为什么被折叠?



