Jumat, 04 Februari 2011

MENU PILIHAN MATRIX C++

//nama : alfi nurramdhan
//kelas: 1 ti 4


#include <constream.h>

void matrix();
void garis();
long luas (long p, long l);


void main()
{
char tombol;

do
{
int pil;
clrscr();

cout<<"M E N U P I L I H A N"<<endl<<endl;
cout<<"1. Penjumlahan Matrix"<<endl;
cout<<"2. Poling"<<endl;
cout<<"3. Luas Persegi"<<endl<<endl;
cout<<"MASUKAN PILIHAN ANDA [1/2/3] : "; cin>>pil;


if (pil==1)
{
matrix();
cout<<endl;
}

if (pil==2)
{
char nama[10];
int ti,mi;
int jum=0;
int tot=0;
clrscr();

garis();
cout<<"\xB3 NO\xB3 N A M A \xB3 TI \xB3 MI \xB3"<<endl;
garis();
cout<<"\xB3 1 \xB3 \xB3 \xB3 \xB3"<<endl;
cout<<"\xB3 2 \xB3 \xB3 \xB3 \xB3"<<endl;
cout<<"\xB3 3 \xB3 \xB3 \xB3 \xB3"<<endl;

for (int x=0;x<3;x++)
{
gotoxy (7,x+4); cin>>nama;
gotoxy (30,x+4); cin>>ti;
jum+=ti;
gotoxy (36,x+4); cin>>mi;
tot+=mi;
}

garis();
cout<<"\xB3 T O T A L \xB3 \xB3 \xB3"<<endl;
gotoxy (30,8); cout<<jum;
gotoxy (36,8); cout<<tot<<endl;
garis();
}

if (pil==3)
{
int x,y;
clrscr();

cout<<"PENGHITUNG LUAS PERSEGI"<<endl<<endl;
cout<<"masukan panjang : "; cin>>x;
cout<<"masukan lebar : "; cin>>y;
cout<<"Luasnya adalah : "<<luas (x,y);
cout<<endl;
}

cout<<endl;
cout<<"KEMBALI KE MENU [Y/T]? "; cin>>tombol;

} while (tombol=='y'||tombol=='Y');
}


void matrix()
{
int x,y;
int a[2][2],b[2][2],c[2][2];
clrscr();

cout<<"\xDA"<<endl;
cout<<"\xB3"<<endl;
cout<<"\xB3"<<endl;
cout<<"\xB3"<<endl;
cout<<"\xC0";
gotoxy (7,1); cout<<"\xBF"<<endl;
gotoxy (7,2); cout<<"\xB3"<<endl;
gotoxy (7,3); cout<<"\xB3"<<endl;
gotoxy (7,4); cout<<"\xB3"<<endl;
gotoxy (7,5); cout<<"\xD9"<<endl;

for (y=0;y<2;y++)
{
for (x=0;x<2;x++)
{
gotoxy ((x+1)*2+1,(y+1)*2);
cin>>a[x][y];
}
}

gotoxy (9,1); cout<<"\xDA"<<endl;
gotoxy (9,2); cout<<"\xB3"<<endl;
gotoxy (9,3); cout<<"\xB3"<<endl;
gotoxy (9,4); cout<<"\xB3"<<endl;
gotoxy (9,5); cout<<"\xC0"<<endl;
gotoxy (15,1); cout<<"\xBF"<<endl;
gotoxy (15,2); cout<<"\xB3"<<endl;
gotoxy (15,3); cout<<"\xB3"<<endl;
gotoxy (15,4); cout<<"\xB3"<<endl;
gotoxy (15,5); cout<<"\xD9"<<endl;
gotoxy (8,3); cout<<"+";

for (y=0;y<2;y++)
{
for (x=0;x<2;x++)
{
gotoxy ((x+1)*2+9,(y+1)*2);
cin>>b[x][y];
}
}

gotoxy (17,1); cout<<"\xDA"<<endl;
gotoxy (17,2); cout<<"\xB3"<<endl;
gotoxy (17,3); cout<<"\xB3"<<endl;
gotoxy (17,4); cout<<"\xB3"<<endl;
gotoxy (17,5); cout<<"\xC0"<<endl;
gotoxy (23,1); cout<<"\xBF"<<endl;
gotoxy (23,2); cout<<"\xB3"<<endl;
gotoxy (23,3); cout<<"\xB3"<<endl;
gotoxy (23,4); cout<<"\xB3"<<endl;
gotoxy (23,5); cout<<"\xD9"<<endl;
gotoxy (16,3); cout<<"=";

for (y=0;y<2;y++)
{
for (x=0;x<2;x++)
{
gotoxy ((x+1)*2+17,(y+1)*2);
c[x][y]=a[x][y]+b[x][y];
cout<<c[x][y];
}
}
}


void polling()
{

}


long luas (long p, long l)
{
int z;
z=p*l;
return (z);
}


void garis()
{
for (int n=0;n<=38;n++)
{
cout<<"\xC4";
}
cout<<endl;
}

Tidak ada komentar:

Posting Komentar