Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Permenkaret Permenkaret is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 351
Rep Power: 14
Permenkaret mempunyai hidup yang Normal
Default TANYA : Bagaimana cara mengatasi error runtime 202?



Gan mau tanya bagaimana cara mengatasi error runtime 202 pada pascal?

Ada program Mencari subsequence bersama terpanjang. Kalau inputnya pendek output panjang LCS dan LCSnya keluar tapi kalau inputnya panjang Output LCSnya gaq keluar. Yang keluar hanyalah panjang LCS saja dan muncul error runtime 202 pada function LCS....




Quote:





program LongestCommonSubsequence;

uses wincrt;



type

tabel = array[0..100, 0..100] of integer;

var

X, Y : string;

tab : tabel;

i, j : integer;



function max (a : integer; b : integer) : integer;

begin

if (b > a) then max := b else max := a;

end;



procedure BentukTabelLCS (S1,S2 : string; var T : tabel);

var k,l :integer;

begin

k := length(S1);

l := length(S2);

for i:=1 to k do

for j:=1 to l do

if (S1[i] = S2[j]) then

T[i,j] := T[i-1,j-1] + 1

else if T[i-1,j] >= T[i,j-1] then

T[i,j] := max (T[i,j-1], T[i-1,j])

else

T[i,j] := T[i,j-1];

end;





function LCS (i,j :integer) : string;

begin

if (i = 0) or (j = 0) then

LCS := ''

else if X[i] = Y[j] then

LCS := LCS(i-1, j-1) + X[i]

else

begin

If tab[i,j-1] > tab[i-1,j] then

LCS := LCS(i, j-1)

Else

LCS := LCS (i-1, j);

end;

end;



begin

write('Inputkan Sequence S1 : ');readln (X);

write('Inputkan Sequence S2 : ');readln (Y);

BentukTabelLCS (X, Y, tab);

writeln ('Panjang LCS yang diperoleh adalah : ',tab[length(X), length(Y)]);

writeln ('Longest Common Subsequence yang diperoleh adalah ','( ',LCS(length(X), length(Y)),' )');

end.









Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 07:31 AM.


no new posts