求问一下各位大佬关于字符串反转问题
c语言吧
全部回复
仅看楼主
level 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int funcf(char a[])
{
char b[100]="";
int i = 0, j = 0, n = strlen(a);
for (i = 0; i < 100; i++)
{
b[i] = a[n - 1 - j];
j++;
}
printf("%s\n%s\n", a, b);
int x = strcmp(b,a);
return x;
}
int main()
{
char a[100];
scanf_s("%s", a, sizeof(a));
int funcf(char a[]);
int x;
x = funcf(a);
printf("%d\n", x);
if (x ==0)
printf("True.\n");
else
printf("False.\n");
return 0;
}
2021年01月01日 06点01分 1
level 2
为什么这个字符串,我输入的是word,反转后是drow烫烫烫烫烫呢
2021年01月01日 06点01分 2
level 2
求大佬解答
2021年01月01日 06点01分 3
level 1
你可以把funcf里的for循环改成这样试试
for (i = 0; i < n; i++)
b[i] = a[n - 1 - i];
2021年01月01日 07点01分 4
吧务
level 14
没有结束标记
2021年01月01日 08点01分 5
请问要在哪里加呢
2021年01月01日 08点01分
@银河之力223 字符串末尾
2021年01月01日 08点01分
@GTA小鸡 我还是不太懂,我们老师没有交过结束标记,能麻烦您详细说下在哪个语句末尾吗
2021年01月01日 09点01分
@银河之力223 老师没教就自己看书
2021年01月01日 09点01分
level 13
烫就对了,这么冷的天,电脑也受不了啊[滑稽]
2021年01月01日 10点01分 6
1