Thứ Hai, 9 tháng 5, 2022

GNEN PASCAL

var s,t:string;
    i,j,k,x,code,n:longint;

procedure nhap;
begin
    readln(s);
    n:=length(s);
end;

procedure xuat(x:longint;c:char);       //xuat x ki tu c lien tiep
begin
    for i:=1 to x do write(c);
end;

function xau_to_so(t:string):longint;
var res,x:longint;
begin
    res:=0;
    for i:=1 to length(t) do
    begin
        x:=ord(t[i])-48;
        res:=res*10+x;
    end;
    exit(res);
end;


procedure giai;
var i:longint;
begin
    t:='';
    for i:=1 to n do
    begin
        if ('0'<=s[i]) and (s[i]<='9') then
            t:=t+s[i]
        else
        if (t<>'') then
        begin
            x:=xau_to_so(t);
            xuat(x,s[i]);
            t:='';
        end
        else write(s[i]);

    end;
end;

begin
    assign(input,'gnen.inp');reset(input);
    assign(output,'gnen.out');rewrite(output);
    nhap;
    giai;
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.