//Nama : Muhammad Zuhri
//NIM : 2016140614
//Kelas : 04TPLP011
//Tugas Akhir Struktur Data Pertemuan 6.cpp
#include <iostream>
#include <conio.h>
using namespace std;
main()
{
char nama[40];
int nim;
bool ketemu;
int posisi[25];
int c,i,banyak=0;
int data[25]={34,8,50,74,87,90,12,25,20,30,35,45,40,22,29,72,60,55,53,12,32,33,12,41,12};
cout<<"Nama : "; gets(nama);
cout<<"NIM : "; cin>>nim;
cout<<"\nData : ";
for(i=0;i<25;i++)
{
cout<<data[i]<<" ";
}
cout<<"\n\nData yang ingin di cari : "; cin>>c;
for (i=0;i<25;i++){
if (data[i]==c){
ketemu=true;
posisi[banyak]=i+1;
banyak++;
}
}
if (ketemu)
{
cout<<"Data : "<<c;
cout<<"\nDitemukan sebanyak "<<banyak;
cout<<"\nPada posisi ke ";
for(i=0;i<banyak;i++){
cout<<posisi[i]<<" ";
}
}
else
{
cout<<"Data "<<c<<" tidak di temukan";
}
getch();
}
Hasil Outputnya seperti gambar dibawah ini :
Semoga materi struktur data ini bermanfaat bagi teman-teman yang membutuhkannya :)
Jumat, 01 Juni 2018
Home »
» Tugas Akhir Pertemuan 6 SEARCHING
Tugas Akhir Pertemuan 6 SEARCHING
Related Posts:
Tugas Akhir Pertemuan 3 STRUCTURE//Nama : Muhammad Zuhri //NIM : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 3.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More
Tugas Akhir Pertemuan 5 FUNCTION//Nama : Muhammad Zuhri //NIM : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 5.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More
Tugas Akhir Pertemuan 4 POINTER//Nama : Muhammad Zuhri //NIM : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 4.cpp #include <iostream> #include <conio.h> #include <windows.h… Read More
Tugas Akhir Pertemuan 7 SORTING//Nama : Muhammad Zuhri //NIM : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 7.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More
Tugas Akhir Pertemuan 8 SORTING (Lanjut 1)//Nama : Muhammad Zuhri //NIM : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 8.cpp #include <iostream> #include <stdio.h> #include <conio.h&g… Read More
0 komentar:
Posting Komentar