kenapa saya gunakan fungsi for , printf ? karena cara ini cukup simple dan tidak perlu cape untuk mengetik dan lebih irit
berikut contoh script nya :
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
int a[5][4][2]={
{{1,2},{3,4},{5,6},{7,8}},
{{9,10},{11,12},{13,14},{15,16}},
{{17,18},{19,20},{21,22},{23,24}},
{{25,26},{27,28},{29,30},{31,32}},
{{33,34},{35,36},{37,38},{39,40}},
};
for(int i=0;i<5;i++){
for(int j=0;j<4;j++){
for(int k=0;k<2;k++){
printf("%d \t",a[i][j][k]);
}
}
printf("\n");
}
getch();
}
#include <conio.h>
#include <iostream.h>
main()
{
int a[5][4][2]={
{{1,2},{3,4},{5,6},{7,8}},
{{9,10},{11,12},{13,14},{15,16}},
{{17,18},{19,20},{21,22},{23,24}},
{{25,26},{27,28},{29,30},{31,32}},
{{33,34},{35,36},{37,38},{39,40}},
};
for(int i=0;i<5;i++){
for(int j=0;j<4;j++){
for(int k=0;k<2;k++){
printf("%d \t",a[i][j][k]);
}
}
printf("\n");
}
getch();
}
Bila di run, maka hasilnya seperti gambar di bawah :
0 komentar:
Posting Komentar