swadmin 2022-02-03 20:04 采纳率: 90%
浏览 7
已结题

这道Pascal代码哪里错了,请大家发一下正确代码

var

n,p1,p2,dian:integer;

a,b:array[1..10000] of integer;

procedure qq;

var

s1,s2:ansistring;

q1,q2,i:integer;

begin

readln(n);

readln(s1);

readln(s2);
p1:=length(s1);

p2:=length(s2);
q1:=pos('.',s1);

q2:=pos('.',s2);
if q10

then begin

dian:=p1-q1; p1:=p1-1;

delete(s1,q1,1);

end;
if q20

then begin

dian:=dian+p2-q2; p2:=p2-1;

delete(s1,q2,1);

end;
for i:=1 to p1 do

if s1[i] in ['A'..'G']

then a[p1-i+1]:=ord(s1[i])-55

else a[p1-i+1]:=ord(s1[i])-ord('0');
for i:=1 to p2 do

if s2[i] in ['A'..'G']

then b[p2-i+1]:=ord(s2[i])-55

else b[p2-i+1]:=ord(s2[i])-ord('0');

end;

procedure main;

var

s:string;

i,j,qq,aa:integer;

c:array[1..10000] of integer;

begin

fillchar(c,sizeof(c),0);

for i:=1 to p1 do

for j:=1 to p2 do

c:=c+b[j]*a[i];
if c[p1+p2]0

then qq:=p1+p2

else qq:=p1+p2-1;
for i:=1 to qq do

if c[i]>=n

then begin

c:=c+(c[i] div n);

c[i]:=c[i] mod n;

end;
if c[qq+1]0

then qq:=qq+1;
s:='';
for i:=1 to qq do

if c[i]>=10

then s:=s+chr(c[i]+55)

else s:=s+chr(c[i]+ord('0'));
if dian>0

then begin

insert('.',s,dian+1);

qq:=qq+1; aa:=0;
for i:=1 to qq do

if s[i]='0'

then inc(aa)

else break;
if s[aa+1]='.'

then delete(s,1,aa+1)

else delete(s,1,aa);
end;
qq:=length(s);

for i:=qq downto 1 do

if s[i]'0'

then break;

if s[i]='.'

then begin

insert('0',s,1);

i:=i+1;

end;
for j:=i downto 1do

write(s[j]);

writeln;

end;
begin

qq;

main;

end.


  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 2月11日
    • 创建了问题 2月3日

    悬赏问题

    • ¥20 WPF MVVM模式 handycontrol 框架, hc:SearchBar 控件 Text="{Binding NavMenusKeyWords}" 绑定取不到值
    • ¥15 需要手写数字信号处理Dsp三个简单题 不用太复杂
    • ¥15 数字信号处理考试111
    • ¥100 关于#audobe audition#的问题,如何解决?
    • ¥15 allegro17.2生成bom表是空白的
    • ¥15 请问一下怎么打通CAN通讯
    • ¥20 如何在 rocky9.4 部署 CDH6.3.2?
    • ¥35 navicat将excel中的数据导入mysql出错
    • ¥15 rt-thread线程切换的问题
    • ¥15 高通uboot 打印ubi init err 22