ttkuilei @ 2022-07-27 14:28:30
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
char a[40010]={'0'};
int i=1,sum=0;
while(cin>>a[i]) i++;
cout<<sqrt(i);
for(int j=1;j<i;j++) {
if(a[j]==a[j-1]) sum++;
else {
cout<<sum<<" ";
sum=1;
}
}
cout<<sum;
return 0;
}
是while(cin>>a[i])
那里输入没停吗??
[疑惑]
by ttkuilei @ 2022-07-27 14:41:57
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
char a[40010]={'0'};
int i=1,sum=0;
while(scanf("%c",&a[i])!=EOF) i++;
cout<<sqrt(i);
for(int j=1;j<i;j++) {
if(a[j]==a[j-1]) sum++;
else {
cout<<sum<<" ";
sum=1;
}
}
cout<<sum;
return 0;
}
这样还是输不出来
by qczrz6v4nhp6u @ 2022-07-27 14:42:06
@tangjiayang Ctrl+Z是这样的
by yinpeichu2021 @ 2022-07-27 14:43:17
多了个^Z
后换行
by ttkuilei @ 2022-07-27 14:43:50
@DogSeven ?
不是按吗
by qczrz6v4nhp6u @ 2022-07-27 14:44:06
@tangjiayang 不i--
的话长度会多一,sqrt(i)
就不是整数
by qczrz6v4nhp6u @ 2022-07-27 14:46:34
@tangjiayang 雀食,按完^Z
后要换行
by ttkuilei @ 2022-07-27 14:47:47
OK
能输出了
by ttkuilei @ 2022-07-27 14:48:05
蟹蟹
by ttkuilei @ 2022-07-27 14:50:20
@DogSeven
可是我i--之后还是小数
by ttkuilei @ 2022-07-27 14:50:58
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
char a[40010]={'0'};
int i=1,sum=0;
while(scanf("%c",&a[i])!=EOF) i++;
cout<<sqrt(--i)<<" ";
for(int j=1;j<=i;j++) {
if(a[j]==a[j-1]) sum++;
else {
cout<<sum<<" ";
sum=1;
}
}
cout<<sum;
return 0;
}