Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Apr 2013
Offline Last Active Apr 25 2013 07:46 AM

#5055205 How to copy a 1-D array into a 2-D array

Posted by on 20 April 2013 - 07:56 AM

Hey Guys according to that i find a code like:


include <iostream>
using namespace std;
#define MAX 10
int A1D[MAX];
int A2D[MAX][MAX];
int main()
//Init A1D Array
for (int i=0;i<MAX;i++) A1D[i]=i+1;
//Convert to A2D
for (int i=0;i<MAX;i++)
for (int j=0;j<MAX;j++)
if (j+1<=A1D[i]) A2D[i][j]=A1D[i];
else A2D[i][j]=0;
return 0;