您的位置:首页 > 其它

字符串反转-简单题

2015-08-28 00:00 113 查看
摘要: 输入:abcd
输出:dcba
得分:98

#include "stdafx.h"
#include<iostream>
using namespace std;

void reverse(char *start,char*end)
{
while(start<end)
{
char t=*start;
*(start++)=*end;
*(end--)=t;
}
}

int main()
{
char s[100];
cin.getline(s,100);
char *start=s;
char *end =s;
while(*end)
end++;
end--;
reverse(start,end);
cout<<s;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: