LAPORAN PRAKTIKUM QUIS
Disusn Oleh :
Riski Yoga Kusumadya
201101019
Dosen :
Yosef Murya Kusuma Ardhana, S.T
JURUSAN SISTEM INFORMASI
SEKOLAH TINGGI ILMU KOMPUTER (STIKom)
"YOS SUDARSO"
PURWOKERTO
2012
TUGAS MEMBUAT MATRIKS 2 DIMENSI DAN 3 DIMENSI DENGAN MENGGUNAKAN WHILE DAN SWITCH CASE
Listing program switch case
// Name : quis_array.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
int i,j,x;
int huruf_A[8][41]=
{
{1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,0,0,0,1,1, 0,1,1,1,1,1,1,1},
{1,1,0,0,0,0,1,1, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,0,1, 0,1,1,1,0,1,1,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,0,1,1, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,0,0, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,1,1,1,1,1,0, 0,0,0,0,1,1,0,0, 0,1,1,1,1,1,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,1,1,0,0, 0,0,0,0,1,1,0,0, 0,1,1,1,1,1,1,1, 0,1,1,1,1,0,0,0, 0,0,0,0,1,1,0,0},
{1,1,1,0,0,1,1,0, 0,0,0,0,1,1,0,0, 0,0,0,0,0,0,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,1,1,0, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,0,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,0,0,0,1,1, 0,1,1,1,1,1,1,1},
};
int huruf[5][9][9]={
{
{1,1,1,1,1,1,1,1},
{1,1,0,0,0,0,1,1},
{1,1,0,0,0,0,1,1},
{1,1,1,1,1,1,1,0},
{1,1,0,0,1,1,0,0},
{1,1,1,0,0,1,1,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,1,1,1,1,1,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,1,1,0,0,0,0,1},
{0,1,1,0,0,0,0,0},
{0,1,1,1,1,1,1,1},
{0,1,1,1,1,1,1,1},
{0,0,0,0,0,0,1,1},
{0,1,1,0,0,0,1,1},
{0,1,1,1,1,1,1,1}
},
{{0,1,1,0,0,0,1,1},
{0,1,1,0,0,1,1,0},
{0,1,1,0,1,1,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,0,1,1,0,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,0,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0}
},
};
cout<<"pilih matrik yang anda inginkan??";
cout<<"\n1.Dua Dimensi";
cout<<"\n2.Tiga dimensi";
cout<<"\npilih :";
cin>>x;
switch(x)
{
case 1:
for (i=0;i<8;i++)
{
for (j=0;j<41;j++)
if (huruf_A[i][j]==1)
cout<<"*";
else
cout<<"\x20";
cout<<endl;
}
break;
case 2:
int i,j,k;
for (i=0;i<5;i++)
{
for (j=0;j<8;j++)
{
for(k=0;k<8;k++)
if(huruf[i][j][k]==1)
cout<<"*";
else
cout<<"\x20";
cout<<endl;
}
cout<<endl;
}
break;
}
return x;
return 0;
}
Output program
Listing Program while
// Name : quis_array.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
int array[1];
int x,i,j,k;
int duadimensi[8][41]=
{
{1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,0,0,0,1,1, 0,1,1,1,1,1,1,1},
{1,1,0,0,0,0,1,1, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,0,1, 0,1,1,1,0,1,1,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,0,1,1, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,0,0, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,1,1,1,1,1,0, 0,0,0,0,1,1,0,0, 0,1,1,1,1,1,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,1,1,0,0, 0,0,0,0,1,1,0,0, 0,1,1,1,1,1,1,1, 0,1,1,1,1,0,0,0, 0,0,0,0,1,1,0,0},
{1,1,1,0,0,1,1,0, 0,0,0,0,1,1,0,0, 0,0,0,0,0,0,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,1,1,0, 0,0,0,0,1,1,0,0, 0,1,1,0,0,0,1,1, 0,1,1,0,1,1,0,0, 0,0,0,0,1,1,0,0},
{1,1,0,0,0,0,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,0,0,0,1,1, 0,1,1,1,1,1,1,1},
};
int tigadimensi[5][9][9]={
{
{1,1,1,1,1,1,1,1},
{1,1,0,0,0,0,1,1},
{1,1,0,0,0,0,1,1},
{1,1,1,1,1,1,1,0},
{1,1,0,0,1,1,0,0},
{1,1,1,0,0,1,1,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,1,1,1,1,1,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,1,1,0,0,0,0,1},
{0,1,1,0,0,0,0,0},
{0,1,1,1,1,1,1,1},
{0,1,1,1,1,1,1,1},
{0,0,0,0,0,0,1,1},
{0,1,1,0,0,0,1,1},
{0,1,1,1,1,1,1,1}
},
{{0,1,1,0,0,0,1,1},
{0,1,1,0,0,1,1,0},
{0,1,1,0,1,1,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,0,1,1,0,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,0,1,1}
},
{{0,1,1,1,1,1,1,1},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,1,0,0}
},
};
array[0]=duadimensi[8][41];
array[1]=tigadimensi[5][9][9];
while (1)
{
cout<<"Pilih array untuk menampilkan nama : \n";
cout<<"0 = Array 2D \n1 = Array 3D";
cout<<"\nPilih : ";
cin>>x;
if((x==0))
for (i=0;i<8;i++)
{
for (j=0;j<41;j++)
if (duadimensi[i][j]==1)
cout<<"*";
else
cout<<"\x20";
cout<<endl;
}
if((x==1))
for (i=0;i<5;i++)
{
for (j=0;j<9;j++)
{
for(k=0;k<9;k++)
if(tigadimensi[i][j][k]==1)
cout<<"*";
else
cout<<"\x20";
cout<<endl;
}
cout<<endl;
}
break;
}
return 0;
}
Output program
Tidak ada komentar:
Posting Komentar