Variable Sized Arrays

  • + 0 comments

    I did the same thing not dynamically but using 2D static arrays , .I even tried reading new line character with scanf (). Im getting segmentation fault error can some one help me regading the same.

    include

    include

    include

    include

    include

    using namespace std;

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int a[100000][300000],n,q,i,m,j,s; scanf("%d %d\n",&n,&q); printf("%d %d",n,q); scanf("%d",&i);

    for(i=0;i<n;i++)
    {   scanf("%d ",&s);
        for(j=0;j<s;j++)
        {
            scanf("%d ",&a[i][j]);
        }
            scanf("\n");
    }
    
    for(i=0;i<q;i++)
    {
        scanf("%d %d",m,n);
        printf("%d %d",a[m][n]);
    }
    return 0;
    

    }