Home » » Program Sequential Search

Program Sequential Search

Written By Unknown on Rabu, 16 Mei 2012 | 19.40


            Program Searchingseq1;
            Uses Wincrt;
        const
                   Nmaks = 100;
            Type
                   Larikint = array [1..Nmaks] of integer;
            Var
                   l : larikint;
                   X,N : Integer;
                   Found : Boolean;
            Procedure isiarray(var L: larikint; N : integer);
            Var
                   K : integer;
            Begin
                   For k:= 1 to N do
                   Begin
                        Write (‘Masukkan data indeks ke-‘,k,’==>’);
                         Read (L[k]);
                   End;
        end;
            Procedure seqsearch (L: larikint; N,X: integer; var ketemu: boolean);
            Var
                   K : integer;
            Begin
                   K := 1;
                   While (k<N) and
                   (L[k]<>X) do
                   Begin
                        K := k + 1;
                        End;
                        If L[k]=X then
                        Ketemu := true
                        Else
                        Ketemu := false;
                   End;
            Begin
                   Write(‘Masukkan banyak data =’); read(N);
                    Isiarray (l,N);
                    Write(‘Masukkan data yang akan dicari =’); read(X);
                     Seqsearch(l,N,X,found);
                     If found then
                        Write(X,’ditemukan’)
                     Else
                        Write(X,’tidak ditemukan’);
            End.



           

Share this article :

0 komentar:

Posting Komentar

Terimakasih Telah membaca artikel kami. Silahkan tinggalkan komentar anda disini.

 
Support : Dunia Matematika | Dunia Fisik dan Fiksi
Copyright © 2013. Blog Berbagi Ilmu - All Rights Reserved
Template Created by AM Published by Aeroplane
Proudly powered by Blogger