c语言 不用数组直接输出

P1319 压缩技术

wuhuqifeia @ 2021-11-11 23:27:51

int main() {
    int N = 0;
    int num = 0,flag=0;
    scanf("%d", &N);
    for (int i = 1; i <= N * N;) {
        scanf("%d", &num);
        if (flag == 0) {
            for (int j = 0; j < num;j++,i++) {

                printf("0");
                if (i % N == 0)
                    printf("\n");
            }
            flag = 1;
            continue;
        }
        else if (flag == 1) {
            for (int j = 0; j < num; j++,i++) {

                printf("1");
                if (i % N == 0)
                    printf("\n");
            }
            flag = 0;
        }
    }
}

by simonfake @ 2021-11-11 23:34:37

orz tlqtj


by Andrewzdm @ 2021-11-12 09:21:50

tlqtj, jbl


|