为什么不输出啊喂~

P1320 压缩技术(续集版)

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 Fr0sTy @ 2022-07-27 14:29:13

EOF


by yinpeichu2021 @ 2022-07-27 14:35:42

是在本地?


by 野生小卒 @ 2022-07-27 14:36:22

输入没停吧,可以用cin.eof()判断有没有读到文件尾


by ttkuilei @ 2022-07-27 14:36:32

@yinpeichu2021 嗯


by yinpeichu2021 @ 2022-07-27 14:37:22

要按下Ctrl+Z


by GOODBALA_233 @ 2022-07-27 14:37:36

输入的时候死循环了吧(应该)


by qczrz6v4nhp6u @ 2022-07-27 14:38:04

@tangjiayang 输入完成之后加个Ctrl+Z


by qczrz6v4nhp6u @ 2022-07-27 14:39:10

@tangjiayang 而且读完之后i要--


by ttkuilei @ 2022-07-27 14:39:56

@DogSeven 按了之后多了个^Z


by ttkuilei @ 2022-07-27 14:40:59

@DogSeven

why i--?


| 下一页