|
|
back to boardAccess violation, but works true om my pc! Help! #include <iostream> using namespace std; int main() { int** m; long n; cin>>n; m = new int*[n]; for (long i=0; i<n; i++) { m[i]=new int[2]; m[i][1]=-1; } for (long j=0; j<n; j++) { int g, t; cin>>g>>t; if (j==0) { m[0][0]=g; m[0][1]=t; continue; } else for (long i=0; i<=j; i++) {
if (m[i][1]==t) while (m[i][1]==t && i<j) i++; else if (m[i][1]>t && m[i][i]!=-1) continue;
if (i==j) { m[j][0]=g; m[j][1]=t; break; } { for (long p=j; p>i; p--) { m[p][0]=m[p-1][0]; m[p][1]=m[p-1][1]; } m[i][0]=g; m[i][1]=t; break; } break; } } for (int i=0; i<n ;i++) { cout<<m[i][0]<<" "<<m[i][1]<<'\n'; } delete[] *m; return 0; } Re: Access violation, but works true om my pc! Help! Is not advisable to use dynamic memory. I recommend you use STL <vector> |
|
|