这个题解看不懂,我的问题在讨论里
查看原帖
这个题解看不懂,我的问题在讨论里
546830
XSean楼主2022/8/15 22:53

第11~14行看不懂,第42~45行看不懂

#include <stdio.h>

int main(void)
{
	char map[200][201];
	int i,j;
	int flag = 0,r = 0,count = 0;
	
	while(scanf("%s", map[r]) != EOF)//11
	{//12
		r++;//13
	}//14
	printf("%d", r);
	for(i = 0; i < r; i++)
	{
		for(j = 0; j < r; j++)
		{
			if(map[i][j] == '0')
			{
				if(flag) //在判断字符是否为'1'的状态下,出现了'0',则输出结果
				{
					printf(" %d", count);
					flag = 0;
					count = 0;
				}
				count++;
			}
			else
			{
				if(!flag) //在判断字符是否为'0'的状态下,出现了'1',则输出结果 
				{
					printf(" %d", count);
					count = 0;
					flag = 1;
				}
				count++;
			}
		}
	}
	if(count > 0)//42
	{//43
		printf(" %d", count); //压缩码里的最后一个数  //44
	}//45
	
	return 0;
} 
2022/8/15 22:53
加载中...