求助一题C语言题目
想了好久还没想出来T_T{:5_100:} {:5_100:} {:5_100:} {:10_266:} 本帖最后由 lyjlyj 于 2017-12-9 14:25 编辑#include<stdio.h>
#include<stdlib.h>
#define LEN 100
int main()
{
char array;
int count;
int i,is_one_ahead;
int tail;
while(gets(array)!=NULL)
{
for(i=0;i<LEN;i++)
{
count=0;
}
i=0;
is_one_ahead=1;
tail=-1;
while(1)
{
if(array!='\0')
{
if(array=='0'&&is_one_ahead == 1)
{
tail++;
is_one_ahead = 0;
count++;
}
else if(array=='1'&&is_one_ahead ==0)
{
tail++;
is_one_ahead = 1;
count++;
}
else
{
count++;
}
}
else
{
break;
}
i++;
}
for(i=0;i<=tail;i++)
i<tail?printf("%d ",count):printf("%d\n",count);
}
return 0;
}
页:
[1]