#include
#include
#include
//procedure tampilan
void tampilan(int data[],int jum){
cout<<"Data : ";
for (int i=0; i
max=data[i];
}
return max;
}
//procedure mencari nilai minimum
void minimum(int data[], int jum, int *min){
*min=data[0];
for (int i=1; i
if (data[i]>=data[j]){
tukar(&data[i],&data[j]);
}
}
}
cout<<"Data setelah di urut :";
for (int i=1; i<=jum; i++){
cout<=i+1; j--){
if (data[i]<=data[j]){
tukar(&data[i],&data[j]);
}
}
}
cout<<"Data setelah di urut :";
for (int i=1; i<=jum; i++){
cout<0)&&(data[j] > p))
{
data[j + 1] = data[j];
j = j-1;
}
data[j+1] = p;
}
cout<<"Data setelah di urut :";
for (int i=1; i<=jum; i++){
cout<0)&&(data[j] < p))
{
data[j + 1] = data[j];
j = j-1;
}
data[j+1] = p;
}
cout<<"Data setelah di urut :";
for (int i=1; i<=jum; i++){
cout<>x;
cout<<"=Kolom matrik I :";cin>>y;
cout<<"=Masuakan Ordo Matrik B (max 10x10) !\n";
cout<<"=Baris matrik II :"<
cout<<"======================================\n";
if ( (x>10) || (y>10) || (z>10) ){
gotoxy(20,12);cout<<"Masukan Angka di Bawah 10 !\n";
}
else
{
for (i=1;i<=x;i++){
for (j=1;j<=y;j++){
cout<<"=Elemen Matrik A ["<>A[i][j];
}
}
cout<<"======================================\n";
for (i=1; i<=y; i++){
for (j=1; j<=z; j++){
cout<<"=Elemen Matrik B ["<>B[i][j];
}
}
}
cout<<"======================================\n";
for (i=1; i<=x; i++){
for (j=1; j<=z; j++){
C[i][j]=0;
for (k=1; k<=y; k++){
C[i][j]=C[i][j]+(A[i][k]*B[k][j]);
}
}
}
for (i=1; i<=x; i++){
for (j=1; j<=z; j++){
cout<<"=Elemen Matrik C ["< 24 )cout<<"Obesitas";
break;
}
case 2:{
if (imt < 18 )cout<<"Kurus";
else if (imt <= 18 && imt <= 24 )cout<<"Normal";
else if (imt > 24 )cout<<"Obesitas";
break;
}
default : cout<<"Pilihan anda salah !";
}
}
//procedur data kemahasiswaan
void mhs(int jum){
struct data{
char nim[8];
char nama[30];
float IP;
float tugas;
float uts;
float uas;
}mhs[10],temp;
char p='y';
for (int i=1; i<=jum; i++){
cout<<"Data mahasiswa ke "<>mhs[i].nama;
cout<<"Masukan NIM mhs :";cin>>mhs[i].nim;
cout<<"Masukan nilai tgs :";cin>>mhs[i].tugas;
cout<<"Masukan nilai UTS :";cin>>mhs[i].uts;
cout<<"Masukan nilai UAS :";cin>>mhs[i].uas;
mhs[i].IP= (mhs[i].tugas + (2*mhs[i].uts)+ (3*mhs[i].uas))/6;
}
clrscr();
for (int i=1; i<=jum; i++){
cout<<"\nData mahasiswa ke "<=i+1; j--){
if (mhs[i].IP>=mhs[j].IP){
temp = mhs[i];
mhs[i] = mhs[j];
mhs[j] = temp;
}
}
}
if (jum>2){
do{
cout<<"\nUrutkan berdasarkan IP ? (y/t) :";
cin>>p;
cout<<"\nData setelah di urut :";
for (int i=1; i<=jum; i++){
cout<<"\nData mahasiswa ke "<>pilih;
switch (pilih){
case 1: {cout<<"Jumlah data yang ingin di inputkan :"; cin>>jum;
for (int i=0; i
}
tampilan(data,jum);
max=maksimum(data,jum);
cout<<"\nNilai Maxsimumnya :"<
for (int i=0; i
}
tampilan(data,jum);
minimum(data,jum,&min);
cout<<"\nNilai minimumnya :"<
for (int i=0; i
}
tampilan(data,jum);
rata2(data,jum);
break;
}
case 4:{ int p;
do{
clrscr();
cout<<"\t\tPengurutan bubel sort";
cout<<"\n1. Askending ";
cout<<"\n2. Deskending";
cout<<"\nMasukan Pilihan anda :";cin>>p;
switch (p){
case 1: { cout<<"\nMasukan Jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nMasukan data ke "<>data[i];
}
bubel_as(data,jum);
break;
}
case 2: { cout<<"\nMasukan Jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nMasukan data ke "<>data[i];
}
bubel_ds(data,jum);
break;
}
default: cout<<"\nBukan pilihan falid";
}
}while (p !=1 && p!=2);
break;
}
case 5: { int p;
do{
clrscr();
cout<<"\t\tPengurutan isertion sort";
cout<<"\n1. Askending ";
cout<<"\n2. Deskending";
cout<<"\nMasukan Pilihan anda :";cin>>p;
switch (p){
case 1: { cout<<"\nMasukan Jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nMasukan data ke "<>data[i];
}
isert_as(data,jum);
break;
}
case 2: { cout<<"\nMasukan Jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nMasukan data ke "<>data[i];
}
insert_ds(data,jum);
break;
}
default: cout<<"\nBukan pilihan falid";
}
}while (p !=1 && p!=2);
break;
}
case 6: { char kata[20];
clrscr();
cout<<"\nmasukan kata :";cin>>kata;
polindrom(kata);
break;
}
case 7: { int A[10],B[10];
int jum;
clrscr();
cout<<"\nMasukan jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nmasukan Nilai array A yang ke "<>A[i];
}
for (int j=1; j<=jum; j++){
cout<<"\nmasukan Nilai array B yang ke "<
}
irisan(A,B,jum);
break;
}
case 8: { int A[10],B[10];
int jum;
clrscr();
cout<<"\nMasukan jumlah data :";cin>>jum;
for (int i=1; i<=jum; i++){
cout<<"\nmasukan Nilai array A yang ke "<>A[i];
}
for (int j=1; j<=jum; j++){
cout<<"\nmasukan Nilai array B yang ke "<
}
kurang(A,B,jum);
break;
}
case 9: { int A[10],B[10];
int jum1,jum2;
clrscr();
cout<<"\nMasukan jumlah data array A :";cin>>jum1;
for (int i=0; i
}
cout<<"\nMasukan jumlah data array B :";cin>>jum2;
for (int j=0; j
}
gabung(A,B,jum1,jum2);
break;
}
case 10: {
perkalian();
break;
}
case 11: {
float berat,tinggi;
int jk;
cout<<"Masukan berat badan anda dalam kilogram :";cin>>berat;
cout<<"Masukan tinggi badan anda dalam satuan meter :";cin>>tinggi;
cout<<"Jenis kelamin anda L=1 P=2:";cin>>jk;
massa(berat,tinggi,jk);
break;
}
case 12: {
int jum;
cout<<"Jumlah mahasiswa :";cin>>jum;
mhs(jum);
break;
}
default: cout<<"\nBukan pilihan falid";
}
cout<<"\nUlangi (y/t) ??"; cin>>lagi;
} while (toupper (lagi)=='y');
}
Minggu, 17 Januari 2010
Contoh Program di c++
Minggu, Januari 17, 2010
Galiarta
No comments
0 comments:
Posting Komentar