#include<stdio.h>
#include<conio.h>
#define MAX_STACK 10
typedef struct STACK {
int top;
char data[10][10];
};
STACK tumpuk;
void inisialisasi(){
tumpuk.top = -1;}
int IsFull(){
if(tumpuk.top == MAX_STACK-1) return 1; else return 0;}
int IsEmpty(){
if(tumpuk.top == -1) return 1; else return 0;}
void Push(char d[10]){
tumpuk.top++;
strcpy(tumpuk.data[tumpuk.top],d);}
void Pop(){
printf(”******************************\n”);
printf(”DATA YANG TERAMBIL ADALAH = %s\n”,tumpuk.data[tumpuk.top]);
tumpuk.top–;
printf(”******************************\n”);
}
void Clear(){
tumpuk.top=-1;}
void TampilStack(){
for(int i=tumpuk.top;i>=0;i–){
printf(”******************************\n”);
printf(”DATA YANG SEKARANG ADALAH : %s\n”,tumpuk.data[i]);
}}
int main(){
int pil;
inisialisasi();
char dt[10];
do{
printf(”%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n”);
printf(”==> Created by :\n”);
printf(” ==> Nama : Evelyn\n”);
printf(” ==> Operating Sytem : Ubuntu Linux Gusty Gibbon 7.10\n”);
printf(”|===========================================|\n”);
printf(”|=============== |MENU UTAMA| ==============|\n”);
printf(”|===========================================|\n”);
printf(”1. push (Untuk Menambah Stack)\n”);
printf(”2. pop (Untuk Mengambil Stack Teratas)\n”);
printf(”3. print (Untuk Menampilkan Seluruh Data Yang Ada Di Dalam Stack)\n”$
printf(”4. clear (Untuk Mengosongkan Stack)\n”);
printf(”5. exit (keluar dari program)\n\n”);
printf(”Masukkan Pilihan Anda : “);scanf(”%d”,&pil);
switch(pil){
case 1: if(IsFull() != 1){
printf(”******************************\n”);
printf(”DATA YANG DI INPUT = “);scanf(”%s”,dt);
Push(dt);
printf(”******************************\n”);
}
else printf(”\n Data Sudah penuh!\n”);
printf(”\n”);
break;
case 2: if(IsEmpty() != 1)
Pop();
else
printf(”\nDATA MASIH KOSONG!\n”);
printf(”\n”);
break;
case 3: if(IsEmpty() != 1)
TampilStack();
else
printf(”\nDATA => MASIH KOSONG !\n”);
printf(”\n”);
break;
case 4: Clear(); printf(”\nDATA ===> SUDAH KOSONG !\n”);
printf(”\n”);
break;
}
}while(pil != 5);
getch();
clrscr();
}
Saturday, December 7, 2013
program menu queue
#include<stdio.h>
#include<conio.h>
#define MAX 10
int queue[MAX],front=-1,rear=-1;
void insert_element();
void delete_element();
void display_queue();
int main()
{
int option;
clrscr();
do
{
printf("\n\n");
printf("+===================+ \n");
printf("| Menu Queue | \n");
printf("+===================+ \n");
printf("1.Insert Queue \n");
printf("2.Delete Queue \n");
printf("3.Display Queue \n");
printf("4.Exit \n");
printf("Enter your choice: \n");
scanf("%d",&option);
switch(option)
{
case 1: insert_element();
break;
case 2: delete_element();
break;
case 3: display_queue();
break;
case 4: return 0;
default :
printf("Salah Memasukkan Pilihan tuh . . ! \n");
}
}
while(option!=4);
return 0;
}
void insert_element()
{
int num;
printf("\n Enter the number to be inserted: ");
scanf("%d",&num);
if(front==0 && rear==MAX-1)
printf("\n Queue OverFlow Occured");
else if(front==-1&&rear==-1)
{
front=rear=0;
queue[rear]=num;
}
else if(rear==MAX-1 && front!=0)
{
rear=0;
queue[rear]=num;
}
else
{
rear++;
queue[rear]=num;
}
}
void delete_element()
{
int element;
if(front==-1)
{
printf("\n Underflow");
}
element=queue[front];
if(front==rear)
front=rear=-1;
else
{
if(front==MAX-1)
front=0;
else
front++;
printf("\n The deleted element is: %d",element);
}
}
void display_queue()
{
int i;
if(front==-1)
printf("\n No elements to display");
else
{
printf("\n The queue elements are:\n ");
for(i=front;i<=rear;i++)
{
printf("\t %d",queue[i]);
}
}
}
#include<conio.h>
#define MAX 10
int queue[MAX],front=-1,rear=-1;
void insert_element();
void delete_element();
void display_queue();
int main()
{
int option;
clrscr();
do
{
printf("\n\n");
printf("+===================+ \n");
printf("| Menu Queue | \n");
printf("+===================+ \n");
printf("1.Insert Queue \n");
printf("2.Delete Queue \n");
printf("3.Display Queue \n");
printf("4.Exit \n");
printf("Enter your choice: \n");
scanf("%d",&option);
switch(option)
{
case 1: insert_element();
break;
case 2: delete_element();
break;
case 3: display_queue();
break;
case 4: return 0;
default :
printf("Salah Memasukkan Pilihan tuh . . ! \n");
}
}
while(option!=4);
return 0;
}
void insert_element()
{
int num;
printf("\n Enter the number to be inserted: ");
scanf("%d",&num);
if(front==0 && rear==MAX-1)
printf("\n Queue OverFlow Occured");
else if(front==-1&&rear==-1)
{
front=rear=0;
queue[rear]=num;
}
else if(rear==MAX-1 && front!=0)
{
rear=0;
queue[rear]=num;
}
else
{
rear++;
queue[rear]=num;
}
}
void delete_element()
{
int element;
if(front==-1)
{
printf("\n Underflow");
}
element=queue[front];
if(front==rear)
front=rear=-1;
else
{
if(front==MAX-1)
front=0;
else
front++;
printf("\n The deleted element is: %d",element);
}
}
void display_queue()
{
int i;
if(front==-1)
printf("\n No elements to display");
else
{
printf("\n The queue elements are:\n ");
for(i=front;i<=rear;i++)
{
printf("\t %d",queue[i]);
}
}
}
program hitung gaji C++
# include <stdio.h>
# include <conio.h>
# include <iostream.h>
main()
{
char nk[20];
float gol,pen,golongan,pend,jjk,a,juml,total,gaji;
cout<<" ====================================================="<<endl;
cout<<" Program Hitung Honor Karyawan Kontrak PT.DINGIN DAMAI\n";
cout<<" ====================================================="<<endl;
cout<<endl;
cout<<" Nama Karyawan : ";gets(nk);
cout<<" Golongan : ";cin>>gol;
cout<<" Pendidikan (SMU[1]/D1[2]/D3[3]/S1[4]): ";cin>>pen;
cout<<" Jumlah Jam Kerja : ";cin>>jjk;
gaji=300000;
if(gol==1 && pen==1)
{golongan=0.05*300000;
pend=0.025*300000;
}
if(gol==2 && pen==1)
{golongan=0.1*300000;
pend=0.025*300000;
}
if(gol==3 && pen==1)
{golongan=0.15*300000;
pend=0.025*300000;
}
if(gol==1 && pen==2)
{golongan=0.05*300000;
pend=0.05*300000;
}
if(gol==2 && pen==2)
{golongan=0.1*300000;
pend=0.05*300000;
}
if(gol==3 && pen==2)
{golongan=0.15*300000;
pend=0.05*300000;
}
if(gol==1 && pen==3)
{golongan=0.05*300000;
pend=0.2*300000;
}
if(gol==2 && pen==3)
{golongan=0.1*300000;
pend=0.2*300000;
}
if(gol==3 && pen==3)
{golongan=0.1*300000;
pend=0.2*300000;
}
if(gol==1 && pen==4)
{golongan=0.05*300000;
pend=0.3*300000;
}
if(gol==2 && pen==4)
{golongan=0.1*300000;
pend=0.3*300000;
}
if(gol==3 && pen==3)
{golongan=0.15*300000;
pend=0.3*300000;
}
if(jjk>=8)
{
a=jjk-8;
juml=a*3500;
}
else
{
juml=0;
}
total=golongan+pend+juml+300000;
clrscr();
cout<<"karyawan Yang Bernama= "<<nk<<endl;
cout<<"Honor Yang Diterima "<<endl;
cout<<"Honor Tetap = Rp. "<<gaji<<endl;
cout<<"Tunjangan Jabatan = Rp. "<<golongan<<endl;
cout<<"Tunjangan Pendidikan = Rp. "<<pend<<endl;
cout<<"Honor Lembur = Rp. "<<juml<<endl;
cout<<"Jumlah = ____________+"<<endl;
cout<<"Honor Yang Diterima Rp. "<<total<<endl;
getch();
}
# include <conio.h>
# include <iostream.h>
main()
{
char nk[20];
float gol,pen,golongan,pend,jjk,a,juml,total,gaji;
cout<<" ====================================================="<<endl;
cout<<" Program Hitung Honor Karyawan Kontrak PT.DINGIN DAMAI\n";
cout<<" ====================================================="<<endl;
cout<<endl;
cout<<" Nama Karyawan : ";gets(nk);
cout<<" Golongan : ";cin>>gol;
cout<<" Pendidikan (SMU[1]/D1[2]/D3[3]/S1[4]): ";cin>>pen;
cout<<" Jumlah Jam Kerja : ";cin>>jjk;
gaji=300000;
if(gol==1 && pen==1)
{golongan=0.05*300000;
pend=0.025*300000;
}
if(gol==2 && pen==1)
{golongan=0.1*300000;
pend=0.025*300000;
}
if(gol==3 && pen==1)
{golongan=0.15*300000;
pend=0.025*300000;
}
if(gol==1 && pen==2)
{golongan=0.05*300000;
pend=0.05*300000;
}
if(gol==2 && pen==2)
{golongan=0.1*300000;
pend=0.05*300000;
}
if(gol==3 && pen==2)
{golongan=0.15*300000;
pend=0.05*300000;
}
if(gol==1 && pen==3)
{golongan=0.05*300000;
pend=0.2*300000;
}
if(gol==2 && pen==3)
{golongan=0.1*300000;
pend=0.2*300000;
}
if(gol==3 && pen==3)
{golongan=0.1*300000;
pend=0.2*300000;
}
if(gol==1 && pen==4)
{golongan=0.05*300000;
pend=0.3*300000;
}
if(gol==2 && pen==4)
{golongan=0.1*300000;
pend=0.3*300000;
}
if(gol==3 && pen==3)
{golongan=0.15*300000;
pend=0.3*300000;
}
if(jjk>=8)
{
a=jjk-8;
juml=a*3500;
}
else
{
juml=0;
}
total=golongan+pend+juml+300000;
clrscr();
cout<<"karyawan Yang Bernama= "<<nk<<endl;
cout<<"Honor Yang Diterima "<<endl;
cout<<"Honor Tetap = Rp. "<<gaji<<endl;
cout<<"Tunjangan Jabatan = Rp. "<<golongan<<endl;
cout<<"Tunjangan Pendidikan = Rp. "<<pend<<endl;
cout<<"Honor Lembur = Rp. "<<juml<<endl;
cout<<"Jumlah = ____________+"<<endl;
cout<<"Honor Yang Diterima Rp. "<<total<<endl;
getch();
}
Subscribe to:
Posts (Atom)