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 bamboo12345 @ 2022-07-16 22:28:21
@Clouderr scanf要用的话要写scanf(“ %c”),要不然用cin
by bamboo12345 @ 2022-07-16 22:29:00
要不然会读入不可见字符
by Clouderr @ 2022-07-16 22:29:50
@bamboo123 但我全用对了
by bamboo12345 @ 2022-07-16 22:30:20
emmmm
by bamboo12345 @ 2022-07-16 22:30:49
你这map还是关键字呢
by bamboo12345 @ 2022-07-16 22:31:33
@Clouderr
by Clouderr @ 2022-07-16 22:32:13
@bamboo123 !我家电脑上不是……
by Clouderr @ 2022-07-16 22:32:38
我改一下
by bamboo12345 @ 2022-07-16 22:33:00
@Clouderr 你没计算n……
by Clouderr @ 2022-07-16 22:33:47
#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("in.in","r",stdin);
/*freopen("out.out","w",stdout); */
int i,j,n,k,temp;
char num[201][201],c,last;
scanf("%c",&c);
for (n=0;c!='\n';n++)
{
num[0][n]=c;
scanf("%c",&c);
}
for (i=1;i<n;i++)
{
for (j=0;j<n;j++)
{
scanf("%c",&num[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 (num[i][j]==last) temp++;
else
{
out[k]=temp;
k++;
temp=1;
}
last=num[i][j];
}
}
out[k]=temp;
k++;
printf("%d ",n);
for (i=0;i<k;i++)
{
printf("%d ",out[i]);
}
fclose(stdin);
/*fclose(stdout);*/
return 0;
}