ymls667 @ 2020-12-29 00:14:05
#include<stdio.h>
#include<string.h>
int main()
{
char a[7];
scanf("%s",&a);
for (int i = strlen(a);i >= 0;i--)
{
printf("%c",a[i]);
}
return 0;
}
为什么这一串代码在本地输入输出都没问题,都是提交上去就WA了呢,大神们求解!
by _caiji_ @ 2020-12-29 00:18:13
&a?不是a吗,数组名=数组地址
by _caiji_ @ 2020-12-29 00:20:58
还有int i=strlen(a)要改成int i=strlen(a)-1,为了不越界
by CGDGAD @ 2020-12-29 06:42:07
#include<stdio.h>
#include<string.h>
int main()
{
char a[7];
scanf("%s", a);
for (int i = strlen(a) - 1;i >= 0;i--)
{
printf("%c",a[i]);
}
return 0;
}
by ymls667 @ 2021-02-09 15:47:48
@caijianhong 感谢指正
by ymls667 @ 2021-02-09 15:48:07
@NSObject 非常感谢解决了问题