`
wsql
  • 浏览: 11716506 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

逆序输出字符串

 
阅读更多

#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
int i,n;
char temp;
cout<<"请输入一串字符:";
cin>>str;
n=str.size();
for(i=0;i<n/2;i++)
{

temp=str[i];

str[i]=str[n-i-1];

str[n-i-1]=temp;

}
cout<<str<<endl;
return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics