conversion of 1 to 2 dimensional array

sourcecode ....


#include <iostream.h>

#include <conio>

int main(){

int A[12]={1, 2, 3, 4, 5, 6, 7, 8, 9};

int B[10][10];

cout << "Array 1 dimensi\n";

for(int i=0; i<9; i++){

cout <<" " << A[i];

}

cout << endl;

cout << "Array 2 dimensi\n";

int i=0;

while(i<9){

for(int j=0; j<3; j++){

for(int k=0;k<3; k++){

B[j][k]=A[i];

i++;

}

}

}

for(int i=0; i<3; i++){

for(int j=0; j<3; j++){

cout << B[i][j] << " ";

}

cout << endl;

}

getch();

return 0;

}

Posted on Juli 13, 2011, in Alprog. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: