Arrays Introduction

  • + 4 comments

    First of all thanks for sharing your solution. I really appreciate it. But i found a bug. There is no exit condition for the first while loop. It will keep writing in the unauthorised memory and crash. It should be like this.

    int main()
    {
        int N,i=0;
        cin>>N;
        int *A = new int[N];
        while(cin>>A[i++] && (i < N));
        while(cout<<A[--N]<<' ' && N);
        delete[] A;
        return 0;
    }