求助!!!全WA了,被知道怎么改

P1320 压缩技术(续集版)

@[LiamZou](/user/972716) ``` int main() { char a[20000]; int n=0, i = 0, cent[200] = { 0 }, j = 0, k = 0; while (cin >> a[i++]);//输入所有元素 n = sqrt(i);//计算出数组的长度n; if (a[0] == '1')//跳过第一个字符为‘1’的情况 { cent[0] = 0;//将计数数组第一个元素设置为0 k++; } while (j < i) { if ((a[j] != a[j - 1] && j != 0))//字符变化则计数数组开始下一个元素的计数,j!=0避免数组越界 k++; cent[k]++; j++;//遍历 } cout << n << " "; for (int s = 0; s < k; s++) cout << cent[s] << " "; return 0; } ``` 有错艾特我,我也是小趴菜可能不太严谨哈哈哈
by jkluio1 @ 2024-03-09 17:05:36


@[jkluio1](/user/1077407) 太牛了,谢谢终于AC了!
by LiamZou @ 2024-03-10 10:04:21


|