Arsip: remove duplicate string
more 14 years ago
r_rie
alo sob semua,
mo nanya lagi nih gmana ya caranya ngilangin char yg sama dalam suatu string,
misalkan 'aabbcdee' trus hasilnya jadi 'abcde'
ada yg bisa bantu gak, thanks,.. :P :P
more 14 years ago
DelphiExpert
1. Sediakan hash table
2. Scan char dlm string, masukkan char yg ditemukan kedalam hash table jika tidak ditemukan, concat hasil := hasil + char
3. kalo ditemukan tinggal skip aja lanjut ke next charakter
more 14 years ago
DelphiExpert
ngantuk2 daripada bikinin code snippet nemu ini monggo diolah sendiri...
more 14 years ago
n3o_cybertech
iseng2 asal jadi aja, tercipta kode sperti ini :
procedure TForm1.RemoveDuplicateString(var ASource: string);
var
i: Integer;
begin
for i:=Length(ASource) downto 1 do
begin
if i < Length(ASource) then
begin
if ASource[i] = ASource[i + 1] then
Delete(ASource,i,1);
end;
end;
end;
monggo klo ada yang lebih simple :)
ubah karakter "<" menjadi "<"
more 14 years ago
sikuper85
@n3o_cybertech: iseng2 asal jadi aja, tercipta kode sperti ini :gini lebih simpel ga yah...monggo klo ada yang lebih simple :) ubah karakter "<" menjadi "<"procedure TForm1.RemoveDuplicateString(var ASource: string); var i: Integer; begin for i:=Length(ASource) downto 1 do begin if i < Length(ASource) then begin if ASource[i] = ASource[i + 1] then Delete(ASource,i,1); end; end; end;
procedure TForm1.RemoveDuplicateStringV2(var ASource: string);
var
i: Integer;
begin
for i:=Length(ASource)-1 downto 1 do
if ASource[i] = ASource[i + 1] then
Delete(ASource,i,1);
end;
more 14 years ago
n3o_cybertech
@mas_kofa: @n3o : itu kalo abjadnya urut...kalo gak urut begimano ayo....???
procedure TForm1.RemoveDuplicateString(var ASource: string);
var
i,idx: Integer;
begin
for i:= 1 to Length(ASource) do
begin
for idx := Length(ASource) downto i + 1 do
if ASource[i] = ASource[idx] then
Delete(ASource,idx,1);
end;
end;
:Dmore ...
- Pages:
- 1
- 2
reply |
Report Obsolete
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 3 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 4 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 11 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 11 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 11 years ago
Random Topic
- cara baca string per karakter
by yoppie in Hal umum tentang Pascal Indonesia more 15 years ago - DBGrid & Shortcut pada tombol
by imunk in Enginering more 19 years ago - Asynchronous Socket Error 10053
by ivan in Hal umum tentang Pascal Indonesia more 17 years ago - [ASK]tanya code print
by Iansx in Tip n Trik Pemrograman more 17 years ago - Program Kasir tanpa database di client
by nick04 in Network, Files, I/O & System more 14 years ago - Image Grayscale.....
by yadi in Hal umum tentang Pascal Indonesia more 16 years ago - Audio Reccorder
by w11 in Lain-lain more 13 years ago - help mo masukin itemindex diradiogroup ke DB
by tegecool in Bedah Kasus more 15 years ago - Installer Dephi 7.0 Error
by Dedy_007 in Enginering more 16 years ago - Modular Programming di Delphi
by bagussb in Tip n Trik Pemrograman more 16 years ago