为啥啥都输出不出来,EOF咋用

P1319 压缩技术

yanghaoyu123 @ 2024-11-18 21:36:52

#include <iostream>
#include<cstdio>
using namespace std;
int main(){
    int n;
    cin>>n;
    int x=0;
    int ss=0;
    int a=0;
    while(scanf("%d",a) != EOF){
        if (x%2==0){
            for (int i=0;i<a;i++){
                if(ss%n==0){
                    cout<<endl;
                }
                cout<<0;
                ss+=1;
            }
        }
        else{
            for (int i=0;i<a;i++){
                if(ss%n==0){
                    cout<<endl;
                }
                cout<<1;
                ss+=1;
            }
        }
        x+=1;
    }

    return 0;
}

by yanghaoyu123 @ 2024-11-18 21:52:09

@mayike确实,谢谢,已关


by 13389660737ljx @ 2024-11-20 20:40:37

我记得是~scanf("%d",&a)!=EOF呀,我习惯写while(cin>>a)


by 13389660737ljx @ 2024-11-20 20:41:22

我也不确定


上一页 |