Home » , , » contoh script c++ array dua dimensi

contoh script c++ array dua dimensi

//array dimensi dua
#include<cstdlib>
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
int i,j;
int data_jual[4][4];
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
cout<<"Data ke- "<<i<<","<<j<<endl;
cout<<"Jumlah Penjualan :";
cin>>data_jual[i][j];
}
}
cout<<"NO  2001  2002  2003"<<endl;
cout<<"---------------------------"<<endl;

for(i=1;i<=3;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
for(j=1;j<=3;j++)
{
cout<<setiosflags(ios::right)<<setw(4)<<i;
cout<<data_jual[i][j];
cout<<"   ";
}
cout<<endl;
}
cout<<"---------------------------"<<endl;
system("PAUSE");
system("PAUSE");
return 0;
}

0 komentar:

Posting Komentar