Array Multidimensi (Contoh 1)
#include
<conio.h>
#include
<stdio.h>
#include
<iostream.h>
#include
<iomanip.h>
void
main()
{
int
i,j,k;
float
data[2][4][3]={
{
{100,200,300},
{150,240,360},
{250,300,460},
{250,300,460} },
{
{100,200,300},
{120,250,310},
{140,250,340},
{100,400,350} }
};
cout<<"============================================================";
cout<<endl;
cout<<"tahunhasiltahun";
cout<<endl;
cout<<"ke.
ke======================================================";
cout<<endl;
cout<<" 2002 2003 2004";
cout<<endl;
cout<<"============================================================";
cout<<endl;
for
(i=0;i<2;i++)
{
for
(j=0;j<4;j++)
{
cout<<setiosflags(ios::left)<<setw(9)<<i+1;
cout<<setiosflags(ios::left)<<setw(9)<<j+1;
for
(k=0;k<3;k++)
{
cout<<setiosflags(ios::right)<<setw(5);
cout<<data[i][j][k];
cout<<"
";
}cout<<endl;
}cout<<endl;
}
cout<<
"=============================================";
cout<<endl;
getch();
}
Komentar
Posting Komentar