googling.. akhirnya nemu contoh program sederhana membuat tabel, dengan inputan menggunakan array 1 dimensi dan 2 dimensi, semoga bisa jadi refrensi :)
Outputnya:
Codingnya:
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main()
{
int i,s;
char nama[5][20];
float nilai1[5];
float nilai2[5];
double hasil[5];
cout<<"Masukkan jumlah siswa: ";
cin>>s;
clrscr();
for(i=1;i<=s;i++)
{
cout<<"Data Ke - "<<i<<endl;
cout<<"Nama Siswa : "; cin>>nama[i];
cout<<"Nilai Teori : "; cin>>nilai1[i];
cout<<"Nilai Praktek : "; cin>>nilai2[i];
hasil[i] = (nilai1[i] * 0.40)+ (nilai2[i] * 0.60);
cout<<endl;
}
cout<<"--------------------------------------------------"<<endl;
cout<<"No. Nama Siswa Nilai Nilai Hasil"<<endl;
cout<<" Mid Tes FInal Ujian"<<endl;
cout<<"--------------------------------------------------"<<endl;
for(i=1;i<=s;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(20)<<nama[i];
cout<<setprecision(2)<<" "<<nilai1[i];
cout<<setprecision(4)<<" "<<nilai2[i];
cout<<setprecision(8)<<" "<<hasil[i]<<endl;
}
cout<<"------------------------------------------";
cout<<"-------"<<endl;
getch();
}
Outputnya:
Codingnya:
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main()
{
int i, j;
int data_jual[4][4];
clrscr();
for(i=1;i<=3;i++)
{
for(j=1;j<=3;j++)
{
cout<<"Data Ke - "<<i<<" "<<j<<endl;
cout<<"Jumlah Penjulan : ";
cin>>data_jual[i][j];
}
}
cout<<endl;
cout<<"Data Penjualan Pertahun"<<endl;
cout<<"-----------------------"<<endl;
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);
cout<<data_jual[i][j];
cout<<" ";
}
cout<<endl;
}
cout<<"-----------------------"<<endl;
getch();
}