用一个数组装下所有输入,但用int数组好像不行
用string数组,但是循环输入直接while(cin>>s)总是出问题
用a[0].size()得出n,for循环输入
int main() {
/*int b[40001],a,count=0,c=0;
bool flag=0;
while(scanf("%1d",&a)) {
if(a!=flag) flag=!flag;
b[count++]=flag;
}
cout<<sqrt(count)<<' ';
flag=0;
for(int i=0;i<=count;i++) {// <=不然最后一个数输不出来
if(b[i]==flag) c++;
else {
cout<<c<<' ';
flag=!flag;
c=1;
}
}
*/
string a[205];

这篇博客探讨了在解决洛谷P1320问题时遇到的数组存储挑战。尝试使用int数组失败后,作者转向使用string数组,但遇到了循环输入的难题。通过a[0].size()获取n值,并采用特定的for循环输入策略来解决问题。
641

被折叠的 条评论
为什么被折叠?



