Clouderr @ 2022-07-16 22:27:05
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,n,k,temp;
char map[201][201],c,last;
scanf("%c",&c);
for (n=0;c!='\n';n++)
{
map[0][n]=c;
scanf("%c",&c);
}
for (i=1;i<n;i++)
{
for (j=0;j<n;j++)
{
scanf("%c",&map[i][j]);
}
scanf("%c",&c);
}
int out[n*n+1];
temp=0;
last='0';
k=0;
for (i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
if (map[i][j]==last) temp++;
else
{
out[k]=temp;
k++;
temp=1;
}
last=map[i][j];
}
}
out[k]=temp;
k++;
printf("%d ",n);
for (i=0;i<k;i++)
{
printf("%d ",out[i]);
}
return 0;
}
by Clouderr @ 2022-07-17 10:29:46
@bamboo123 WA
by bamboo12345 @ 2022-07-17 11:47:21
@Clouderr 都说了最后n算答案时不要减掉1
by Clouderr @ 2022-07-18 08:12:58
@bamboo123 还是WA
by bamboo12345 @ 2022-07-18 09:53:02
@Clouderr 说实话就我一开始说的问题,不要多去用一个c把换行符吃掉,直接scanf(“ %c”)不会读入不可见字符就好了