Array Berdimensi 3 dengan Bahasa C++

Posted on Updated on



// huruf menggunakan array dimensi 3
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
void garis();
void main()
{
int huruf_A_B[2][8][8]=
 {
 { {0,1,1,1,1,1,0,0}, //kode ASCII huruf A
 {0,1,0,0,0,1,0,0},
 {0,1,0,0,0,1,0,0},
 {1,1,1,1,1,1,1,0},
 {1,1,0,0,0,0,1,0},
 {1,1,0,0,0,0,1,0},
 {1,1,0,0,0,0,1,0},
 {0,0,0,0,0,0,0,0} },

{ {1,1,1,1,1,1,0,0}, //kode ASCII huruf B
 {1,0,0,0,0,1,0,0},
 {1,0,0,0,0,1,0,0},
 {1,1,1,1,1,1,1,0},
 {1,1,0,0,0,0,1,0},
 {1,1,0,0,0,0,1,0},
 {1,1,1,1,1,1,1,0},
 {0,0,0,0,0,0,0,0} }

};
 int i,j,k;
 garis();
 cout<<"Nama : Rudi Sartono"<<endl;
 cout<<"Nim : 8020090070"<<endl;
 cout<<"Kelas : 01PT2"<<endl;
 garis();
 cout<<endl;
 cout<<"PROGRAM ARRAY BERDIMENSI 3"<<endl<<endl;
 for (i=0;i<2;i++)
 {
 for(j=0;j<8;j++)
 {
 for(k=0;k<8;k++)
 if (huruf_A_B[i][j][k]==1)
 cout<<'\xDB';
 else
 cout<<'\x20';

cout<<endl;
 }
 }
 getch();
}
void garis()
{
 cout<<"-----------------------------------";
 cout<<endl;
}

hasil outputnya :

aray dimensi

Program Data kelulusan dengan memanfaatkan data array


//Data kelulusan menggunakan array
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

void garis();
void main()
{
int data_lulus[3][5];
int tahun,jurusan;

clrscr();
 garis();
 cout<<"Nama : Rudi Sartono"<<endl;
 cout<<"Nim : 8020090070"<<endl;
 cout<<"Kelas : 01PT2"<<endl;
 garis();
 cout<<"DATA KELULUSAN MAHASISWA"<<endl<<endl;
 cout<<"a.Jurusan Sistem Informasi "<<endl;
 cout<<"b.Jurusan Teknik Informatika "<<endl;
 cout<<"c.Jurusan Sistem Komputer"<<endl<<endl;

data_lulus[0][0]=50;
 data_lulus[0][1]=75;
 data_lulus[0][2]=100;
 data_lulus[0][3]=130;
 data_lulus[0][4]=150;
 data_lulus[1][0]=15;
 data_lulus[1][1]=35;
 data_lulus[1][2]=50;
 data_lulus[1][3]=80;
 data_lulus[1][4]=105;
 data_lulus[2][0]=9;
 data_lulus[2][1]=15;
 data_lulus[2][2]=15;
 data_lulus[2][3]=18;
 data_lulus[2][4]=25;

while(1)
 { cout<<"Pilih Jurusan (0=SI,1=TI,2=SK): ";
 cin>>jurusan;

 garis();
 if ((jurusan==0)||(jurusan==1)||(jurusan==2)) break;
 }

if(jurusan==0)
 {cout<<"Jurusan Sistem informasi"<<endl;}
 else if(jurusan==1)
 {cout<<"Jurusan teknik Informatika"<<endl;}
 else cout<<"Jurusan Sistem Komputer"<<endl;
 while(1)
 {
 cout<<"Tahun Akademik (2006-2010): ";
 cin>>tahun;
 if ((tahun>=2006)&&(tahun<=2010))
 {
 tahun-=2006; break;
 }
 }

garis();
 cout<<"Jumlah Mahasiswa yang lulus = "<<data_lulus[jurusan][tahun]<<endl;
 getch();
}

void garis()
{
 cout<<"\n-------------------------------------\n";
 cout<<endl;
}

datakelulusan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s