一、运行结果;
二、源代码;
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>
# include <string.h>
//声明颠倒函数;
void reverse(char a[])
{
//初始化变量值;
int i, j;
char t;
//循环颠倒;
for (i = 0, j = strlen(a); i < (strlen(a) / 2); i++, j--)
{
//颠倒;
t = a[i];
a[i] = a[j - 1];
a[j - 1] = t;
}
}
int main()
{
//初始化变量值;
char a[100] = { 0 };
//获取用户输入字符串;
printf("请输入字符串:");
scanf("%s", &a);
//输出用户输入结果;
printf("转换前字符串为:");
printf("%s\n", a);
//调用颠倒函数;
reverse(a);
//输出结果;
printf("转换后的结果为:%s", a);
return 0;
}