BLX32M_10 @ 2022-02-26 21:09:54
RT,
#include <stdio.h>
#include <cmath>
#include <iostream>
int res[100005], sz;
int main()
{
char x, tf = '0';
int n = 0;
while (std::cin >> x)
{
n++;
if (x != tf)
sz++, res[sz]++, tf = x;
else
res[sz]++;
}
printf("%d", std::sqrt(n));
for (int i = 0; i <= sz; i++)
printf(" %d", res[i]);
}
by 一只大龙猫 @ 2022-02-26 21:15:00
@Brooksx 格式化符错了啊……
换成%f
试试
by 一只大龙猫 @ 2022-02-26 21:15:20
或者干脆用cout
by 林志艺 @ 2022-02-26 21:20:30
@Brooksx 用cout吧,sqrt()不是返回整数,要不然根号2怎么办?
验证码fbnq
by BLX32M_10 @ 2022-02-26 21:39:14
@一只大龙猫 @林志艺 谢谢 验证码 82ZZ