jebfghbbcdsl @ 2024-08-05 10:13:51
本人喜欢压行,请各位忍一忍
#include<iostream>
#include<cmath>
using namespace std;
int tmp,ans=-1,cnt,a[40010];char c,flag='0';
int main(){
while(1){
cin>>c,ans++;
if(c==EOF)break;
if(c==flag)cnt++;
else{
a[++tmp]=cnt,cnt=0;
if(flag=='0')flag='1';
else flag='0';
}
}
cout<<int(sqrt(ans))<<' ';
for(int i=1;i<=tmp;i++)cout<<a[i]<<' ';
return 0;
}
by melancholic @ 2024-08-05 10:19:53
死循环了,改好了样例也是错的
#include<iostream>
#include<cmath>
using namespace std;
int tmp,ans=-1,cnt,a[40010];char c,flag='0';
int main(){
while(cin>>c){
ans++;
if(c=='EOF')break;
if(c==flag)cnt++;
else{
a[++tmp]=cnt,cnt=0;
if(flag=='0')flag='1';
else flag='0';
}
}
cout<<int(sqrt(ans))<<' ';
for(int i=1;i<=tmp;i++)cout<<a[i]<<' ';
return 0;
}
by jebfghbbcdsl @ 2024-08-06 08:13:23
@melancholic 所以我该怎么才能AC?
(你倒是说怎么解决啊!!!!!)
by powshell @ 2024-08-08 17:19:01
就不能边输入边输出吗?