nhập 1 dãy biến dổi só nt trong xâu?

1 câu trả lời

 uses crt;
Var
 A:array[1..1000000] of longint;
 i,k,x,j,n,t,d,d1,max,f,v:longint;
 S,S1:string;

  function dn(y:longint):string;
  begin    dn:='';
   str(y,S);
   for v:=length(S) downto 1 do dn:=dn+S[v];
  end;

Begin     clrscr;
 readln(S);

  i:=0;  S1:='';  k:=0; x:=0;  t:=0;  d:=0;  n:=length(S);
 while i<=n do
  begin
   S1:='';
   while ((not (S[i] in ['0'..'9'])) and (i<=n)) do i:=i+1;

   while ((S[i] in ['0'..'9']) and (i<=n)) do

    begin
     S1:=S1+S[i]; i:=i+1;
    end;

   val(S1,x);  k:=k+1;
   A[k]:=x;
   end;
 for i:=1 to k-1 do write(dn(A[i]),' ');
{for i:=1 to k do t:=t+A[i]; writeln('Tong cac so trong xau la: ',t);
 for i:=1 to length(S) do if A[i]>0 then d:=d+1;  writeln('So so trong xau la: ',d);
 for i:=1 to n do if A[i]=f then d1:=d1+1;        writeln('So so x trong xau la: ',d1);
   max:=A[1];
 for i:=1 to k do if max<A[i] then max:=A[i];
   writeln('So lon nhat trong xau la: ',max);
   write('Day so co trong xau la: ');
 for i:=1 to k-1 do write(A[i],' ');}
Readln;
End.

Câu hỏi trong lớp Xem thêm