想了很多久,真的就不明白我哪里不对了?怎么我才是20分。。。。
查看原帖
想了很多久,真的就不明白我哪里不对了?怎么我才是20分。。。。
886639
Liangzheng123楼主2022/12/20 17:30
#include <stdio.h>
#include <string.h>
int main() {
	char s;
	char txt[40000]="x",str[200];
	scanf("%s", str);//先读入第一行
	int n = strlen(str),count=0;
	strcat(txt, str); // 将第一行的内容复制到txt当中
	for (int i = 1; i <= n-1; i++) {
		scanf("%s", str);
		strcat(txt, str);
	}
	printf("%d ", n);
	s = txt[1];
	for (int i = 1; i < strlen(txt); i++) {
		if (s == txt[i]) count++;
		else {
			printf("%d ", count);
			s = txt[i];
			count = 1;
		}
	}
	printf("%d", count);
	return 0;
}

真的就不明白我哪里不对了,求求大佬解答

2022/12/20 17:30
加载中...