#include <stdio.h>
#define N 100
void inverse(char[]);
int main(int argc, int *argv[])
{
int i = 0;
char c,a[N];
printf("input a string:");
gets(a);
puts(a);
inverse(a); //进行字符翻转
puts(a);
system("pause");
return 0;
}
void inverse(char str[])
{
int i;
char c;
int begin = 0, end = strlen(str) - 1,mid = end / 2;
do
{
c = str[end];
str[end --] = str[begin];
str[begin++] = c;
}while(begin < mid);
}
|