View Single Post
Old 15-10-2009, 08:56 AM   #24
Hồ sơ
duyhung123abc
Senior Member
 
duyhung123abc's Avatar
 
Tham gia ngày: Jun 2008
Số bài viết: 206
Tiền: 25
Thanks: 10
Thanked 45 Times in 40 Posts
duyhung123abc is on a distinguished road
Default Ðề: Một số bài toán cần nắm trong tin học

Đây là đoạn code tách chuỗi số từ chuỗi ban đầu
Code:
procedure tachso;
var
  i,j:longint;
begin
  n:=0;
  i:=1;
  while i<=length(s) do
    begin
      j:=i;
      if (s[i]>='0') and (s[i]<='9') then
        begin
          inc(n);
          so[n]:='';
        end;
      while (s[j]>='0') and (s[j]<='9') and (j<=length(s)) do
        begin
          inc(j);
          so[n]:=so[n]+s[j];
          s[j]:='?';
        end;
      while (so[n][1]=0) and (length(so[n])>1) do delete(s,1,1);
      i:=j;
    end;

  while pos(s,'??')>0 do delete(s,pos(s,'??'),1);
end;
__________________
Quyết tâm thành pro

thay đổi nội dung bởi: duyhung123abc, 15-10-2009 lúc 09:02 AM.
duyhung123abc is offline   Trả Lời Với Trích Dẫn