使字符串反序输出
作者:互联网
#include<stdio.h>
#include<math.h>
#include<string.h>
int main() {
void inverse(char str1[]);
char str1[100];
printf("请输入字符串:");//abcdefg
gets_s(str1);
inverse(str1);
printf("新字符串:%s\n",str1);
}
void inverse(char str1[]){
char t;
int i, j;
for (i = 0, j = strlen(str1); i < (strlen(str1) / 2); i++, j--) {
t = str1[i];
str1[i] = str1[j - 1];
str1[j - 1] = t;
}
}
标签:输出,inverse,int,反序,char,字符串,include,str1 来源: https://blog.csdn.net/weixin_51172308/article/details/113835197