来个大佬解惑

P1320 压缩技术(续集版)

seanxie @ 2020-11-18 23:57:40

#include <stdio.h>
#include <math.h>
int main()
{
    int n,i=0;
    int sum1=0,sum2=0;
    int p[40000];
    while((scanf("%1d",&p[i]))!=EOF)
   {
     i++;   
   }
    printf("%.f ",sqrt((float)i));
    for(n=0;n<=i;++n)
    {
       if(p[n]==0)
       {
          sum1++;
          if(sum2>0)
          {
            printf("%d ",sum2);
            sum2=0;
          }
       }
       if(p[n]==1)
       {
          sum2++;
          if(sum1>0)
          {
            printf("%d ",sum1);
            sum1=0;
          }
       }
   }
    return 0;
}

by _CELESTE_ @ 2020-11-19 00:10:54

解啥惑?


by CGDGAD @ 2020-11-19 06:38:56

解啥惑?


|