Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Contoh Program C++

Contoh Program C++

Ratings: (0)|Views: 19,962|Likes:
Published by Eddy Purwoko

More info:

Published by: Eddy Purwoko on Nov 03, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Tugas : Struktur Data C++Nama : Eddy PurwokoNPM : 2008 435 00 845=================================================================================="""""" Program Antrian """"""
Input :
#include<stdio.h>#include<conio.h>void main(){int cek=0, data[20], x, hapus;char pil;do {clrscr();printf("1. Tambah Antrian\n");printf("2. Hapus Antrian\n");printf("3. Lihat Antrian\n");printf("4. Keluar\n");printf("Silahkan masukkan pilihan anda... ");pil=getche();if(pil!='1' && pil !='2' && pil !='3' && pil!='4' )printf("\n\nAnda salah mengetikkan inputan...\n");else{if(pil=='1') //PUSH{if(cek==20)printf("\nAntrian Penuh\n\n");else{printf("\nMasukkan nilai--> ");scanf("%i",&x);data[cek]=x;cek++;}}else{if(pil=='2') //POP{if(cek==0)printf("\nAntrian kosong\n\n");else{hapus=data[0];for(int v=0;v<cek;v++)data[v]=data[v+1];data[cek-1]=NULL;
cek--;printf("\nData dgn nilai=%i terhapus.",hapus);}getch();}else{if(pil=='3') //CEK DATA{if(cek==0)printf("\nAntrian Kosong.\n\n");else{printf("\n");for(int z=0;z<cek;z++){printf(" | ");printf("%i",data[z]);printf(" | ");}}getch();}}}}}while(pil!='4');}
Output :
1. Tambah Antrian2. Hapus Antrian3. Lihat Antrian4. KeluarSilahkan masukkan pilihan anda...( jika tekan 1, maka )Masukkan Nilai -->( Jika tekan 2, maka )Data dgn nilai = terhapuskan.( Jika tekan 3, maka )| nilai yg di masukkan |( Jika tekan 4, maka )Keluar dari program
“”””Program Array””””
Input :
#include<stdio.h>void main(){int A[10],index[10], i,j,k;for(i=0;i<10;i++){printf("Data ke-%d:",i+1);scanf("%d",&A[i]);}printf("Masukkan data yang akan anda cari:");scanf("%d",&k); j=0;for (i=0;i<10;i++){if(A[i]==k){index[j]=i; j++;}}if (j>0){printf("Data %d yang dicari ada %d buah\n",k,j);printf("Data tersebut terdapat dalam index ke :");for(i=0;i<j;i++){printf(" %d ",index[i]);}printf("\n");}else{printf("Data tidak ditemukan dalam array\n");}}

Activity (246)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Ewin Hidayat added this note
mantepppp bunggg!!!!!!!!!!!,,,,,,,,,,,
Azhura Hasan added this note
bagai mana mencari program yag mengunakan array,looping dengan bersamaan?
Zan Ran liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->