字符串反轉-簡單題

#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;
}
相關文章
相關標籤/搜索