# Untitled

unknown
plain_text
3 years ago
2.1 kB
20
Indexable
Never
```uses crt;
const
input='roungding.inp';
output='roungding.out';
var
m,k:string;
f:text;
s:string;
ii,jj,m1,code1:longint;
//lam tron theo thuat toan cua Bom
function lamtron(m:string;n:longint):string; // m='1.23243243223'
var
i,pos,l,tg,tt,code:longint;
s,s1,s2,s3,s4:string;//truoc dau phay la s1, sau dau phay la s2
begin
pos:=1;
l:=length(m);
while(m[pos]<>'.') do inc(pos);
s1:=copy(m,1,pos);
s2:=copy(m,pos+1,l-pos);
//lam tron s2 theo quy tac cua bom , s2=23243243223
i:=length(s2);
while((i>=n) and (s2[i] > '4')) do
begin
val(s2[i-1],tg,code);
if (tg<9) then
begin
inc(tg);
str(tg,s3);
s2[i-1]:=s3[1];
delete(s2,i,1);
end;
if (tg=9) then
begin
tg:=0;
val(s2[i-2],tt,code);
inc(tt);
str(tt,s4);
s2[i-2]:=s4[1];
delete(s2,i,2);
end;
end;
//s1 la truoc dau phay; s2 la sau dau phay sau khi lam tron theo thuat toan cua bom
//s la noi s1 voi s2   s=s1'.'s2
s:=concat(s1,'.',s2);
lamtron:=s;
end;
function sinhso(s7:string;m:longint):string;//sinh so tiep theo sau so s7='123' =>'124', do dai la m=3
var
i,tg,code:longint;
s1,s2:string;
begin
if(s7[m]<'9') then
begin
val(s7[m],tg,code);
inc(tg);
str(tg,s1);
s7[m]:=s1[1];
end;
if(s7[m]='9') then
begin
s7[m]:='0';
val(s7[m-1],tg,code);
if (tg<9) then  inc(tg);
str(tg,s1);
s7[m-1]:=s1[1];
end;
sinhso:=s7;

end;

//ham chinh
begin
clrscr;
assign(f,input);reset(f);