ALPRO
1 item
New Text Document.txt
#include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { int batas; cout<<"Masukan Batas : "; cin>>batas; int array1[batas]; int array2[batas]; for(int i=0;i<batas;i++){ cout<<"Masukan Data Array1 index-"<<i<<" : "; cin>>array1[i]; } cout<<endl; for(int i=0;i<batas;i++){ cout<<"Masukan Data Array2 index-"<<i<<" : "; cin>>array2[i]; } cout<<endl; int baris,kolom; cout<<"Masukan Baris : "; cin>>baris; cout<<"Masukan Kolom : "; cin>>kolom; int jumlah = batas*2; int k=0; int u=0; int array2d[baris][kolom]; for(int i=0;i<baris;i++){ for(int j=0;j<kolom;j++){ if(k<(jumlah/2)){ array2d[i][j]=array1[k]; }else{ array2d[i][j]=array2[u]; u++; } if(k>=jumlah){ array2d[i][j]=0; } k++; } } for(int i=0;i<baris;i++){ for(int j=0;j<kolom;j++){ cout<<array2d[i][j]<<" "; } cout<<endl; } system("PAUSE"); return 0; }
0 komentar:
Posting Komentar