lrh18856925124 @ 2022-11-15 15:07:05
#include <stdio.h>
#include <string.h>
int main()
{
char c[100] = { 'a' };
int a[300];
int i = 0, n = 0;
char c1 = 'a';
do {
scanf("%s", c);
a[i] = strlen(c);
i++;
n = i;
scanf("%c", &c1);
if (c1 == '\n') {
break;
}
} while (1);
for (i = 0; i < n; i++) {
if (i == 0) {
printf("%d", a[i]);
}
else {
printf(",%d", a[i]);
}
}
return 0;
}
by gybtx @ 2022-11-15 15:34:05
不要使用!=\n
请使用!=EOF
,识别文件末尾。
示例:while(scanf("%s", c)!=EOF)
by Lazy_King @ 2023-03-05 21:31:24
@gybtx 佬,为啥用!='\n'判断就不能ac啊!能具体说一下为啥嘛?