求助!

P1319 压缩技术

LFYdemi @ 2024-03-23 19:23:41

¿

#include<iostream>
using namespace std;
int n;
int a[300];
bool k=0;
int full=0;
int main(){

    cin>>n;
    int i=0;
    while(cin>>a[++i]){
        full++;
        for(int j=1;j<=a[i];j++){
            cout<<k;
        }
        k=!k;
        if(full==n){
            full=0;
            cout<<"\n";
        }
    }

    return 0;
}

by MsgNotFound @ 2024-03-23 20:08:15

@LYFdemi 换行问题


by MsgNotFound @ 2024-03-23 20:08:23

@LFYdemi


by LFYdemi @ 2024-03-23 20:12:50

@42_TZY 什么问题O.o


by MsgNotFound @ 2024-03-23 20:35:13

@LFYdemi 换行太少,

比如正确输出:

11111
00000
11111
00000
11111

你的输出就是:

111110000011111
0000011111

by LFYdemi @ 2024-03-23 21:07:15

@42_TZY 我知道啊,所以问题在哪【呆】(**丢死人了)


by I_like_to_CTJ @ 2024-03-23 22:36:24

出什么问题了


by TGLXJ @ 2024-03-27 20:24:31

if(full==n){  
    full=0;
    cout<<"\n";
}

问题在这

if((full+1)%n==0){
            full=0;
            cout<<"\n";
        }

应该改成这样


|