//============================================================================
// Name : Kuis_Array_2D_3D_Case_while.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include
using namespace std;
int main()
{
awal:
int pilihan;
cout<<" Program Array \n ";
cout<<" \n 0. Array 2D ";
cout<<" \n 1. Array 3D ";
cout<<" \n 2. Exit ";
cout<<" \n =============================== \n ";
cout<<" \n Pilihan : \t ";
cin>>pilihan;
switch(pilihan)
{
case 0:
{
int huruf_A[8] [50]=
{
{1,1,1,1,1,1,1,0 ,0,1,1,1,1,1,0,0 ,1,1,1,1,1,1,1,0 ,1,1,1,1,1,1,1,0 ,0,1,1,1,1,1,0,0},
{1,0,0,0,0,0,0,0 ,0,1,0,0,0,1,0,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,0,0,1,0 ,0,1,0,0,0,1,0,0},
{1,0,0,0,0,0,0,0 ,0,1,0,0,0,1,0,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,0,0,1,0 ,0,1,0,0,0,1,0,0},
{1,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,0 ,0,0,0,1,1,0,0,0 ,1,1,1,1,1,1,1,0 ,1,1,1,1,1,1,0,0},
{1,0,0,1,1,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,1,1,0,0,0,0 ,1,1,0,0,0,1,0,0},
{1,0,0,0,0,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,0,1,1,0,0,0 ,1,1,0,0,0,1,0,0},
{1,1,1,1,1,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,1,1,0,0 ,1,1,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0},
};
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<50; j++)
if(huruf_A[i][j]==1)
cout<<"0";
else
cout<<'\x20';
cout<
return 0;
break;
}
case 1:
{
int huruf[5] [8] [8]=
{
{{1,1,1,1,1,1,1,0},
{1,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0},
{1,0,0,1,1,1,1,0},
{1,0,0,0,0,1,1,0},
{1,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0}},
{{0,1,1,1,1,1,0,0},
{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,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,0,0,0,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},
{1,1,1,1,0,0,0,0},
{1,1,0,1,1,0,0,0},
{1,1,0,0,1,1,0,0},
{0,0,0,0,0,0,0,0}},
{{0,1,1,1,1,1,0,0},
{0,1,0,0,0,1,0,0},
{0,1,0,0,0,1,0,0},
{1,1,1,1,1,1,0,0},
{1,1,0,0,0,1,0,0},
{1,1,0,0,0,1,0,0},
{1,1,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0}}
};
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<<"0";
else
cout<<"\x20";
cout<
cout<
return 0;
break;
}
}
return 0;
}
===============================================================================
Hasil Output
2.Array While
Listing Program
//============================================================================
// Name : Kuis_Array_2D_3D_While.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include
using namespace std;
int main()
{
int pilih;
int huruf_A[8] [50]=
{
{1,1,1,1,1,1,1,0 ,0,1,1,1,1,1,0,0 ,1,1,1,1,1,1,1,0 ,1,1,1,1,1,1,1,0 ,0,1,1,1,1,1,0,0},
{1,0,0,0,0,0,0,0 ,0,1,0,0,0,1,0,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,0,0,1,0 ,0,1,0,0,0,1,0,0},
{1,0,0,0,0,0,0,0 ,0,1,0,0,0,1,0,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,0,0,1,0 ,0,1,0,0,0,1,0,0},
{1,0,0,0,0,0,0,0 ,1,1,1,1,1,1,1,0 ,0,0,0,1,1,0,0,0 ,1,1,1,1,1,1,1,0 ,1,1,1,1,1,1,0,0},
{1,0,0,1,1,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,1,1,0,0,0,0 ,1,1,0,0,0,1,0,0},
{1,0,0,0,0,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,0,1,1,0,0,0 ,1,1,0,0,0,1,0,0},
{1,1,1,1,1,1,1,0 ,1,1,0,0,0,0,1,0 ,0,0,0,1,1,0,0,0 ,1,1,0,0,1,1,0,0 ,1,1,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0},
};
while (1)
{
cout<<" Program Array ";
cout<<"\n 0. Array 2D ";
cout<<"\n 1. Array 3D ";
cout<<"\n Pilih : ";
cin>>pilih;
if(pilih==0)
{
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<50; j++)
if(huruf_A[i][j]==1)
cout<<"0";
else
cout<<'\x20';
cout<
return 0;
break;
}
while (1)
{
if (pilih==1)
{
int huruf[5] [8] [8]=
{
{{1,1,1,1,1,1,1,0},
{1,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0},
{1,0,0,1,1,1,1,0},
{1,0,0,0,0,1,1,0},
{1,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0}},
{{0,1,1,1,1,1,0,0},
{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,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,0,0,0,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},
{1,1,1,1,0,0,0,0},
{1,1,0,1,1,0,0,0},
{1,1,0,0,1,1,0,0},
{0,0,0,0,0,0,0,0}},
{{0,1,1,1,1,1,0,0},
{0,1,0,0,0,1,0,0},
{0,1,0,0,0,1,0,0},
{1,1,1,1,1,1,0,0},
{1,1,0,0,0,1,0,0},
{1,1,0,0,0,1,0,0},
{1,1,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0}}
};
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<<"0";
else
cout<<"\x20";
cout<
cout<
return 0;
}
}
return 0;
}
}
==================================================================================
Hasil Output While
Tidak ada komentar:
Posting Komentar