0
#include <stdio.h>
#include <math.h>

int main() {
    int n;
    scanf("%d", &n);
    int rc;
    if(n==(sqrt(n)*sqrt(n))) {
        rc= sqrt(n);
    }
    else {
        rc= sqrt(n)+ 1;
    }
    char str[rc][rc];
    for(int i=0; i<rc; i++) {
        for(int j=0; j<rc; j++) {
            scanf("%c", &str[j][i]);
        }
    }
    for(int i=0; i<rc; i++) {
        for(int j=0; j<rc; j++) {
            printf("%d %d : %c \n", i+1, j+1, str[j][i]);
        }
    }
    return 0;
}

When I executed the above code, I have got the following as output.

As you can see, 2D haven't read the first element. Can anyone say where I am lacking?

0 Answers0