1.求两个正整数(不超过一百位)的和.2.求两个正整数(不超过一百位)的差.用Free pascal
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/21 01:43:08
1.求两个正整数(不超过一百位)的和.2.求两个正整数(不超过一百位)的差.用Free pascal
这两道题都是高精度运算
在这里我给你我的第一题代码 (不超过254位,string最长254,可以用ansistring增加长度)
var a,b,c:string;r,i,h,f,e:integer;
begin
readln(a);
readln(b);
f:=length(a);
e:=length(b);
for i:=1 to abs(f-e) do c:=c+'0';
if f>e then b:=c+b
else a:=c+a;
c:='';
for i:=length(a) downto 1 do
begin
h:=ord(a[i])+ord(b[i])+r-96;
r:=h div 10;
c:=chr(h mod 10+48)+c;
end;
if r>0 then c:='1'+c;
writeln(c);
end.
通过 100分
测试点1: 答案正确 340KB 4MS
测试点2: 答案正确 336KB 4MS
测试点3: 答案正确 340KB 0MS
测试点4: 答案正确 336KB 0MS
测试点5: 答案正确 340KB 0MS
测试点6: 答案正确 336KB 0MS
测试点7: 答案正确 336KB 0MS
测试点8: 答案正确 336KB 0MS
测试点9: 答案正确 336KB 4MS
测试点10: 答案正确 336KB 4MS
手打党! BS抄袭!
LS那个程序就不说了吧.
第二题 楼主可以改下第一题的程序 自己动手试试吧 .呵呵
在这里我给你我的第一题代码 (不超过254位,string最长254,可以用ansistring增加长度)
var a,b,c:string;r,i,h,f,e:integer;
begin
readln(a);
readln(b);
f:=length(a);
e:=length(b);
for i:=1 to abs(f-e) do c:=c+'0';
if f>e then b:=c+b
else a:=c+a;
c:='';
for i:=length(a) downto 1 do
begin
h:=ord(a[i])+ord(b[i])+r-96;
r:=h div 10;
c:=chr(h mod 10+48)+c;
end;
if r>0 then c:='1'+c;
writeln(c);
end.
通过 100分
测试点1: 答案正确 340KB 4MS
测试点2: 答案正确 336KB 4MS
测试点3: 答案正确 340KB 0MS
测试点4: 答案正确 336KB 0MS
测试点5: 答案正确 340KB 0MS
测试点6: 答案正确 336KB 0MS
测试点7: 答案正确 336KB 0MS
测试点8: 答案正确 336KB 0MS
测试点9: 答案正确 336KB 4MS
测试点10: 答案正确 336KB 4MS
手打党! BS抄袭!
LS那个程序就不说了吧.
第二题 楼主可以改下第一题的程序 自己动手试试吧 .呵呵
1.求两个正整数(不超过一百位)的和.2.求两个正整数(不超过一百位)的差.用Free pascal
pascal高精度拆分整数 【问题描述】 输入一个正整数N(不超过一百位),如果N是偶数,则拆分N的各个数字相
用Free Pascal 做 求两个正整数的最大公约数
js验证非0开头的不超过6位的正整数,求正则表达式
若不相等的两个正整数的和,差,积,商之和是一个完全平方数,则称这样的两个数为“智慧数”,如果这两个数均不超过100,求这
求 杜甫(春夜喜雨)的课文题解 不超过一百字 急用 谢谢
求描写景色的片段.不超过一百字
求“囊萤映雪”的两个人物和故事.囊萤:(不超过10字) 映雪:(不超过10字)
求四个不超过70000的正整数,每一个正整数的约数的个数多于100个.
嫦娥奔月的故事缩写(最好不超过一百五十字)
求4个不超过70000的正整数,且每个正整数约数多于100个
用free pascal编程:输入两个数,求他们的最大公因数和最小公倍数