Arsip: Help .. Terjemahin in delphi Dunk ...

 
user image
more 15 years ago

daryl_sukma_gumilar

@ Master2 Delphi Yang Baik .. saya Newbie In Delphi ... Boleh bantuin terjemahin Source code C

Ini Nda ..??

Penting bgt neh ... Trim's KK .. ini Scriptnya #include<iostream> float fuzzymatch( char pattern, char text ); int srchstr( const char str, char c, int pos ); int main() { char text = new char[256]; char pattern = new char[256]; std::cout << "\nPlease enter some text: "; std::cin.getline( text, 256 ); std::cout << "Enter pattern to search: "; std::cin.getline( pattern, 256 ); float result = fuzzymatch( text, pattern ); std::cout << "\nFuzzy match result = " << result; std::cout << "\nthe above strings "; if( result < 0.59 ) { std::cout << "are not very"; } else if( result >= 0.59 && result < 0.7 ) { std::cout << "are quiet"; } else if( result >= 0.7 ) { std::cout << "are very"; } std::cout << " closed syntacticaly. "; delete text; delete pattern; return 0; } int srchstr( const char str, char c, int pos ) { for(int stroff = pos; str[stroff] != 0; ++stroff) { if(str[stroff] == c) { return stroff; } } return -1; } template<class T> void swap( T &a, T &b ) { T temp = a; a = b; b = temp; } bool is_in( int array, int index, int val ) { for(int i=0; i <= index; i++) { if(array[i] == val) return true; } return false; } float fuzzymatch( char pattern, char text ) { int Plen = strlen(pattern); int Tlen = strlen(text); if (Tlen > Plen) { swap(pattern, text); swap(Plen, Tlen); } float cost = 0.0f; float hit = 0.0f; int Textloc = 0; float min_cost = (float)1/Plen; int hit_pos = new int[Plen]; for(int Textoff = 0; Textoff < Plen; ++Textoff) { Textloc = srchstr( text, pattern[Textoff], 0 ); if ( is_in( hit_pos, Textoff, Textloc )) { int Tempoff = Textloc + 1; while( Tempoff < Tlen ) { Textloc = srchstr( text, pattern[Textoff], ++Tempoff ); if ( Textloc != -1 && !is_in( hit_pos, Textoff, Tempoff )) break; } } if (Textloc != -1) { hit_pos[Textoff] = Textloc; int distance = abs(Textloc - Textoff); cost = distance * min_cost; hit += 1 - cost; } } delete hit_pos; return hit/Plen; } Semoga bisa membantu ...
user image
more 15 years ago

wh4nx

setau saya kode tersebut bukan C# hehehehe
user image
more 15 years ago

daryl_sukma_gumilar

Itu C++ Master Sudah saya coba ^_^
user image
more 15 years ago

daryl_sukma_gumilar

Monggo Dicoba Di C++ Kalo Anda Kurang yakin ;-)
user image
more 15 years ago

luckynvic

lumayan panjang... :D :D mudahnya cari padangan fungsi C++ dengan fungsi di delphi, struktur pemrograman di C++ dan struktur pemrograman di Delphi, tipe data yang sesuai... contoh: char *text = new char[256]; -> text:string; std::cout << "\nPlease enter some text: "; -> write('Please enter some text: '); std::cin.getline( text, 256 ); -> readln(text); dst..
user image
more 15 years ago

daryl_sukma_gumilar

@ Mater Lucky : iaa master ... Tapiiii .. banyak juga fungsi2 yang saya blum tau di delphi .. trus cara menuliskanya .. Seperti swap ... Permainan Pointer ... Sepertinya Rumit .. Hhhehehe ...
user image
more 15 years ago

pebbie

swapnya dipake untuk 2 tipe data, bikin aja pake function overloading untuk integer dan string. srchstr mirip (variannya) fungsi Pos, yang pointer itu sebetulnya dynamic array aja kok lainnya kode umum nggak aneh2..
user image
more 15 years ago

daryl_sukma_gumilar

@ master Pebbie : Saya Sudaa Bikin Function Di delphi .. Seperti ini functionya

function StrSimilar (s1, s2: string): Integer;
var hit: Integer;
    p1, p2: Integer;
    l1, l2: Integer;
    pt: Integer;
    diff: Integer;
    hstr: string;
    test: array  of Boolean;
begin
  if Length(s1) < Length(s2) then begin
    hstr:= s2; s2:= s1; s1:= hstr;
  end;
  l1:= Length (s1);
  l2:= Length (s2);
  p1:= 1; p2:= 1; hit:= 0;
  diff:= Max (l1, l2) div 3 + ABS (l1 - l2);
  for pt:= 1 to l1 do test[pt]:= False;
  repeat
    if not test[p1] then begin
      if (s1[p1] = s2[p2]) and (ABS(p1-p2) <= diff) then begin
        test[p1]:= True;
        Inc (hit);
        Inc (p1); Inc (p2);
        if p1 > l1 then p1:= 1;
      end else begin
        test[p1]:= False;
        Inc (p1);
        if p1 > l1 then begin
          while (p1 > 1) and not (test[p1]) do Dec (p1);
          Inc (p2)
        end;
      end;
    end else begin
      Inc (p1);
      if p1 > l1 then begin
        repeat Dec (p1); until (p1 = 1) or test[p1];
        Inc (p2);
      end;
    end;
  until p2 > Length(s2);
  Result:= 100 * hit DIV l1;
end;
Nah Kalo saya mau manggil function tersebut lewat sebuah procedure procedure TForm1.Button1Click(Sender: TObject); Gmana ya Master ... Yg saya ingin cocokkan isi Memo1 dan memo2 .. Dan hasilnya ingin saya tampilkan di Memo3 .. help me all master .. Thx
user image
more 15 years ago

pebbie

procedure TForm1.Button1Click(Sender:TObject);
var i : integer;
function min2(a,b:integer):integer;begin if a<b then result := a else result := b; end;
begin
  {membandingkan seluruh isi memo1 dan memo2}
  Memo3.Lines.Add(inttostr(strsimilar(memo1.lines.text, memo2.lines.text)));
  {membandingkan per baris memo1 dan memo2}
  for i := 0 to min2(memo1.lines.count, memo2.lines.count) do
     Memo3.Lines.Add(inttostr(strsimilar(memo1.lines[i], memo2.lines[i])));
end;
user image
more 15 years ago

daryl_sukma_gumilar

@ Master Pebbbie : Sudaa saya coba master Tapii masii Error :-( .. Errornya bunyinya seperti ini ... [Error] Unit1.pas(36): Illegal character in input file: '&' ($26) [Error] Unit1.pas(36): Undeclared identifier: 'Max' [Error] Unit1.pas(47): Illegal character in input file: '&' ($26) [Error] Unit1.pas(51): Illegal character in input file: '&' ($26) [Error] Unit1.pas(55): Illegal character in input file: '&' ($26) [Error] Unit1.pas(57): Illegal character in input file: '&' ($26) [Error] Unit1.pas(63): Illegal character in input file: '&' ($26) [Error] Unit1.pas(68): 'END' expected but 'UNTIL' found [Error] Unit1.pas(70): 'UNTIL' expected but 'END' found [Error] Unit1.pas(76): Illegal character in input file: '&' ($26) [Error] Unit1.pas(81): For loop control variable must be simple local variable [Error] Unit1.pas(84): ';' expected but '.' found [Error] Unit1.pas(86): Declaration expected but end of file found Mohon Bimbingannya Master....
more ...
Share to
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com