membuat project aplikasi C++ dengan menampilkan loading,dua kolom dan menu utama stack,circular queue,double ended dan linkedlist
artikel ini saya buat di karenakan saya dapat tugas untuk membuat sebuah project program aplikasi yang dapat menempilkan loading,dua kolom dan menu utama stack,circular queue,double ended dan linkedlist
di karenakan tugasnya lumayan susah,karena kali pertama saya membuatnya dan tidak ada referensi satu pun di google mangknya saya buat blog ini mungkin saja dapat bermanfaat bagi temen2 yang barang kali tugasnya sama dengan saya ,,
pertma kita harus membuat program delay / loading dan kemudian kiita membuat program untuk kaper tersebut dengan bingkai,lalu kita buat lagi program stack,trus program circular queue,di lanjut program double ended dan di lanjut program linkedlist,, setelah itu kita gabungkan beberapa program menjadi satu.
nah di bagian ini yang susahnya yakni menggabungkan beberapa program menjadi satu..karena hal itulah mangknya saya buat artikell ini agar tmen2 sekalian dapat belajar dan mungkin melihat script yang saya buat
BERIKUT SAYA TAMPILKN BEBERAPA CONTOH POTO programnya
berikut adalah codingan c++ project aplikasi
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
void delay(void){
int delay;
delay=1;
while(delay<10000000){
delay++;
}
}
// tabel - gotoxy
void gotoxy(int x, int y){
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void clearLine(int xAwal, int yAwal, int xAkhir, int yAkhir){
for(int i = yAwal; i<=yAkhir; i++){
for(int j = xAwal; j<=xAkhir; j++){
gotoxy(j, i);
cout<<" ";
}
}
gotoxy(xAwal, yAwal);
}
#define MAX 10 // aplikasi stack
int top=-1, Stack[MAX];
void aplikasi_struct();
void struct_push(){
clearLine(42,8,87,25);
if(top == MAX-1){
gotoxy(43,8);
cout << ">> Stack sudah Penuh !" << endl;
}else{
top++;
gotoxy(43,9);
cout << ">> Masukan Data : ";
cin >> Stack[top];
gotoxy(43,10);
cout << "Pada Index ke '" << top << "' ";
gotoxy(43,11);
cout << "Data [" << Stack[top] << "] Telah Ditambah ! " << endl;
gotoxy(43,12);
system("pause");
clearLine(42,8,87,25);
aplikasi_struct();
}
}
void struct_pop(){
if(top == -1){
gotoxy(43,16);
cout << ">> Stack Kosong !";
}else{
gotoxy(43,15);
cout << "Data [" << Stack[top] << "]index ke '" << top << "' dalam Stack Diambil !"<<endl;
Stack[top--];
gotoxy(42,32);
cout<<"Press any key to continue"<<endl;
system("pause");
clearLine(42,8,87,25);
aplikasi_struct();
}
}
int struct_clear(){
return top = -1;
system("pause");
aplikasi_struct();
}
void struct_print(){
if (top == -1) {
cout << " Stack : ";
cout << "\n===========================";
cout << " Empty ! \n===========================";
}
else {
cout << " Stack : ";
cout << "\n===========================" ;
for (int i = top; i >= 0; i--){
cout << " ***[ " << Stack[i] << " ]***";
}
cout << "===========================";
}
}
void aplikasi_struct(){
int choose;
do {
// struct_print();
gotoxy(42,8);
cout << "1. Push";
gotoxy(42,9);
cout << "2. Pop";
gotoxy(42,10);
cout << "3. Clear";
gotoxy(42,11);
cout << "4. Exit";
gotoxy(42,12);
cout << "Pergerakan ( TOP ) : " << top;
gotoxy(42,13);
cout << ">> Choose : "; cin >> choose;
switch (choose){
case 1:
struct_push();getch();
break;
case 2:
struct_pop();getch();
break;
case 3:
struct_clear();
gotoxy(42,17);
cout << "Clear Succes" ;
getch();
break;
case 4:
gotoxy(42,18);
cout << "Terima Kasih telah menggunakan program ini :)" ;
getch();
break;
default:
gotoxy(42,19);
cout << "Pilihan tidak ada\t\nMasukan pilihan sesuai dengan daftar";
getch();
break;
system("pause");
}
clearLine(42,8,87,25);
}while(choose !=4);
}
//aplikasi queue
void struct_queue(){
int queue[5];
int depan = -1;
int belakang = -1;
int pilihan, data, i;
do{
clearLine(42,8,70,23);
gotoxy(42,8);
cout<<("MENU\n");
gotoxy(42,9);
cout<<("1. ENQUEUE");
gotoxy(42,10);
cout<<("2. DEQUEUE");
gotoxy(42,11);
cout<<("3. VIEW");
gotoxy(42,12);
cout<<("4. EXIT");
gotoxy(42,13);
cout<<("Pilihan = ");
cin>>pilihan;
switch (pilihan)
{
case 1:
if (belakang < 4 )
{
gotoxy(42,14);
cout<<"Data Masuk = ";
cin>>data;
queue[belakang+1] = data;
belakang++;
if (belakang == 0)
depan = 0;
}
else
gotoxy(42,19);
cout<<"\t\t\t\t\t\tQueue penuh!"<<endl;
break;
case 2:
if (depan <= belakang)
{
gotoxy(42,16);
cout<<"Data keluar = "<<queue[depan];
depan++;
cout<<endl;
}
else
gotoxy(42,20);
cout<<("\t\t\t\t\t\tQueue kosong!")<<endl;
break;
case 3:
gotoxy(42,18);
for(i=depan; i<=belakang; i++)
cout<<queue[i];
break;
}
gotoxy(42,32);
cout<<"Press any key to continue"<<endl;
system("pause");
clearLine(42,8,70,23);
}
while (pilihan != 4);
}
//aplika double ended queue
#define n 10
void INSERTL();
void INSERTR();
void DELETEL();
void DELETER();
void CETAKLAYAR();
void Inisialisasi();
void RESET();
int PIL,F,R,L;
char PILIHAN [1],ANGKA;
char Q[n];
void struct_deque()
{
clearLine(42,8,70,25);
Inisialisasi();
do
{
gotoxy(42,8);
cout<<"======================"<<endl;
gotoxy(42,9);
cout<<" ANIMASI DEQUE "<<endl;
gotoxy(42,10);
cout<<"======================"<<endl;
gotoxy(42,11);
cout<<"1. INSERT KIRI "<<endl;
gotoxy(42,12);
cout<<"2. INSERT KANAN"<<endl;
gotoxy(42,13);
cout<<"3. DELETE KIRI "<<endl;
gotoxy(42,14);
cout<<"4. DELETE KANAN"<<endl;
gotoxy(42,15);
cout<<"5. CETAK ANTRIAN"<<endl;
gotoxy(42,16);
cout<<"6. QUIT"<<endl;
gotoxy(42,17);
cout<<"PILIHAN : ";cin>>PILIHAN;
PIL=atoi(PILIHAN);
switch (PIL)
{
case 1:
INSERTL();
break;
case 2:
INSERTR();
break;
case 3:
DELETEL();
break;
case 4:
DELETER();
break;
case 5:
CETAKLAYAR();
break;
default:
gotoxy(42,25);
cout<<"HATUR NUHUN"<<endl;
break;
}
gotoxy(42,32);
cout<<"Press any key to continue"<<endl;
getch();
system("pause");
clearLine(42,8,70,25);
struct_deque();
}
while (PIL<6);
}
void INSERTL()
{
if(L<n+1)
{
L=L-1;
gotoxy(42,19);cout<<"MASUKAN ANGKA (kiri):";
cin>>ANGKA;
Q[L]=ANGKA;
}
else
gotoxy(42,20);cout<<"\t\t\t\t\t\tAntrian Penuh"<<endl;
}
void INSERTR()
{
if(R<n-1)
{
gotoxy(42,21);cout<<"MASUKAN ANGKA (kanan):";
cin>>ANGKA;
R=R+1;
Q[R]=ANGKA;
}
else
gotoxy(42,22);cout<<"\t\t\t\t\tAntrian Penuh";
}
void CETAKLAYAR()
{
if (L<R+1)
{
for (int i=L;i<=R;i++)
cout<<"Q["<<i<<"]="<<Q[i]<<endl;
}
else
gotoxy(42,23);
cout<<"\tAntrian Kosong"<<endl;
}
void DELETEL()
{
if(L<=R+1)
{
ANGKA=Q[L];
L=L+1;
Q[L++]='1';
gotoxy(42,24);
cout<<"Data kiri yang diambil :"<<ANGKA<<endl;
if(L==n)
RESET();
}
else
cout<<"\tantrian Kosong"<<endl;
}
void DELETER()
{
if (L<=R+1)
{
ANGKA=Q[R];
R=R-1;
Q[R++]='1';
cout<<"Data kanan yang diambil"<<ANGKA<<endl;
if(R==n)
RESET();
}
else
cout<<"Antrian Kosong"<<endl;
}
void Inisialisasi()
{
L=0;
R=-1;
}
void RESET()
{
L=0;
R=-1;
system("pause");
clearLine(42,8,70,25);
struct_deque();
}
//aplikasi linked list
void linked_list();
int pil;
void pilih_ll();
void buat_baru_ll();
void tambah_belakang_ll();
void tambah_depan_ll();
void hapus_belakang_ll();
void hapus_depan_ll();
void tampil_ll();
struct simpul{
char nim[8], nama[80];
int umur;
struct simpul *next;
}mhs, *baru, *awal=NULL, *akhir=NULL, *hapus, *bantu;
void linked_list(){
do{
gotoxy(42,8);
cout<<"APLIKASI LINKED LIST";
clearLine(42,8,70,25);
cout << "MENU SINGLE LINKED LIST";
gotoxy(42,10);
cout << "1. Tambah Depan";
gotoxy(42,11);
cout << "2. Tambah Belakang";
gotoxy(42,12);
cout << "3. Hapus Depan";
gotoxy(42,13);
cout << "4. Hapus Belakang";
gotoxy(42,14);
cout << "5. Tampil";
gotoxy(42,15);
cout << "6. EXIT";
gotoxy(42,16);
cout << "Pilihan anda: ";
cin>>pil;
pilih_ll();
}while (pil!=6);
}
void pilih_ll(){
if(pil==1){
tambah_depan_ll();
}
else if(pil==2){
tambah_belakang_ll();
}
else if(pil==3){
hapus_depan_ll();
}
else if(pil==4){
hapus_belakang_ll();
}
else if(pil==5){
tampil_ll();
}
else if(pil==6){
clearLine(42,8,70,25);
gotoxy(42,15);
cout << "HATUR NUHUN TOS NYOBIAN MAKE APLIKASI IEU :)";
gotoxy(42,32);
cout<<"Press any key to continue"<<endl;
system("pause");
pilih_ll();
}
else{
gotoxy(42,17);
cout<<"Pilihan salah"<<endl;
gotoxy(42,18);
system("pause");
}
}
void buat_baru_ll(){
clearLine(42,8,70,25);
baru=(simpul*)malloc(sizeof(struct simpul));
gotoxy(42,8);
cout << "Input NIM : ";
cin >> baru->nim;
gotoxy(42,9);
cout << "Input Nama : ";
cin >>baru->nama;
gotoxy(42,10);
cout << "Input Umur : ";
cin >> baru->umur;
baru->next=NULL;
}
void tambah_belakang_ll(){
buat_baru_ll();
if(awal==NULL){
awal=baru;
}
else{
akhir->next=baru;
}
akhir=baru;
akhir->next=NULL;
tampil_ll();
}
void tambah_depan_ll(){
buat_baru_ll();
if(awal==NULL){
awal=baru;
akhir=baru;
akhir->next=NULL;
}
else{
baru->next=awal;
awal=baru;
}
tampil_ll();
}
void hapus_depan_ll(){
if(awal==NULL){
clearLine(42,8,70,25);
cout<<"Data kosong";
gotoxy(42,16);
system("pause");
}
else{
hapus = awal;
awal=awal->next;
free(hapus);
}
tampil_ll();
}
void hapus_belakang_ll(){
if(awal==NULL){
clearLine(42,8,70,25);
cout << "Data Kosong";
gotoxy(42,16);
system("pause");
}
else if(awal==akhir){
hapus = awal;
awal=awal->next;
free(hapus);
}
else{
hapus = awal;
while(hapus->next != akhir){
hapus = hapus->next;
akhir=hapus;
hapus=akhir->next;
akhir->next=NULL;
free(hapus);
}
}
tampil_ll();
}
void tampil_ll(){
if(awal==NULL){
clearLine(42,8,70,25);
cout << "Data Kosong";
gotoxy(42,16);
system("pause");
}
else{
bantu=awal;
clearLine(42,8,70,25);
int i = 8;
while(bantu!=NULL){
gotoxy(42,i++);
cout << "NIM : " << bantu->nim;
gotoxy(42,i++);
cout << "NAMA : " << bantu->nama;
gotoxy(42,i++);
cout << "UMUR : " << bantu->umur;
bantu=bantu->next;
i++;
}
gotoxy(42,i-=1);
system("pause");
}
getch();
}
//Akhir aplikasi struct
void setWindow(){
const int width = 800;
const int height = 700;
//SetWindowLong()...
SetWindowPos(GetConsoleWindow(), NULL,
GetSystemMetrics(SM_CXSCREEN)/2 - width/2,
GetSystemMetrics(SM_CYSCREEN)/2 - height/2,
width, height, SWP_SHOWWINDOW);
}
using namespace std;
int main(){
atas :
system("cls");
int i,j,pil;
char ulang;
for(i=30 ; i<=50; i++){
gotoxy(i,12);
system("color A");
printf("*");
gotoxy(i,14);
system("color A");
printf("*");
delay();
}
for(i=1; i<=100; i++){
gotoxy(30,13);
cout<<"MOHON SABAR sedang LOADING. ."<<i<<"%";
gotoxy(50,5);
cout<<"Nama : AHMAD MUTOLIB";
gotoxy(50,6);
cout<<"NIM : 201011450415";
delay();
}
system("cls");
//garis atas
for(i=1 ; i<=100; i++){
gotoxy(i,1);
printf("*");
gotoxy(i,4);
printf("*");
gotoxy(i,26);
printf("*");
gotoxy(i,30);
printf("*");
delay();
}
//garis samping
for(i=1; i<=30; i++){
gotoxy(1,i);
printf("*");
gotoxy(100,i);
printf("*");
delay();
}
//garis tengah
for(i=4;i<=30;i++){
gotoxy(40,i);
printf("*");
delay();
}
//TEKS
gotoxy(30,3);
cout<<"APLIKASI AHMAD MUTOLIB";
//tulisan kiri
gotoxy(10,6);
cout<<"MENU UTAMA";
gotoxy(4,8);
cout<<"1. Aplikasi Stack";
gotoxy(4,10);
cout<<"2. Aplikasi Queue";
gotoxy(4,12);
cout<<"3. Aplikasi Double Ended Queue";
gotoxy(4,14);
cout<<"4. Linked List";
//tulisan tabel kanan atas
gotoxy(60,6);
cout<<"APLIKASI BERJALAn";
gotoxy(4,28);
cout<<"PILIH MENU : ";
cin>>pil;
switch(pil){
case 1:
aplikasi_struct();
break;
case 2:
struct_queue();
break;
case 3 :
struct_deque();
break;
case 4 :
linked_list();
break;
default:
getch();
}
// pilihan
gotoxy(42,28);
cout<<"lanjut atau tidak [y/n] ::";
cin>>ulang;
if(ulang == 'y'){
goto atas;
}
getch();
return 0;
}
dan ini hasil dari codingan tersebut
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeWjAcWWKDzywAmKtU7YKm9OiQXSJjZZ507YTf6YqPn8fJQH1bM_Y8mKprzoA_93MewB6GcdKv28xmrApbGeneoUiDGF0hp7OZZoDJo8LzglKuTyE5eqpJvlolOeAJzWKXgS-SdifIv-CN8_qkX-u6QbmhQZJzsViEmn4y3hLFv8wP9nbBHo3zFibM1g/s1366/2022-04-10%20(16).png
chane youtobe
ahmad mutolib chanel
.png)
.png)
.png)
Komentar
Posting Komentar