It's a code question in C language

Asked 1 years ago, Updated 1 years ago, 307 views

I keep getting errors, but I don't know what's wrong

#include <stdio.h>

void jin(int array_1[7][7]);
void output(int array_2[7][7]);

int main(void) {
    int array[7][7];
    void jin(array);
    void output(array);
}

void jin(array_1[7][7]) {
    int x = 0, y = 4;
    int i;
    for (i = 1; i <= 49; i++) {
        array_1[x][y] == i;
    }
    if (i % 7 == 0) {
        x++;
    }
    else {
        if (x == 0) {
            x = 6;
        }
        else {
            x--;
        }
        if (y == 0) {
            y = 6;
        }
        else {
            y--;
        }

    }

}

void output(array_2[7][7]) {
    int i, j;
    for(i=0;i<7;i++)
        for (j = 0; j < 7; j++) {
            printf("%3d", array_2[i][j]);
        }
    printf("\n");
}

c

2022-12-27 18:31

1 Answers

#include <stdio.h>

void jin(int array_1[7][7]);
void output(int array_2[7][7]);

int main(void) {
    int array[7][7] = {};
    jin(array);
    output(array);
}

void jin(int array_1[7][7]) {
    int x = 0, y = 3;
    int i;
    for (i = 1; i <= 49; i++) {
        array_1[x][y] = i;

        if (i % 7 == 0) {
            x++;
        }
        else {
            if (x == 0) {
                x = 6;
            }
            else {
                x--;
            }
            if (y == 0) {
                y = 6;
            }
            else {
                y--;
            }

        }
    }

}

void output(int array_2[7][7]) {
    int i, j;
    for(i=0;i<7;i++) {
        for (j = 0; j < 7; j++) {
            printf("%3d ", array_2[i][j]);
        }
        printf("\n");
    }
}


2022-12-27 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.