竖式乘法 Pascal

作者&投稿:展菲 (若有异议请与网页底部的电邮联系)
pascal编程的乘法运算: 从键盘读入2个100以内的正整数,进行乘法运算并以竖式输出。~

var a,b:integer;
begin
readln(a,b);
writeln(a:5);
writeln('×',b:3);
writeln(a*(b mod 10):5);
if b>9 then
begin
writeln(a*(b div 10):4);
writeln(a*b:5);
end;
end.

vari,j,k:byte;s1,s2,s3:string[3];beginreadln(i,j);str(i:0,s1);str(j:0,s2);writeln(' ',s1);writeln('+ ',s2);writeln('----');k:=i+j;str(k:0,s3);if length(s3)=3 then writeln(' ',s3)else writeln(' ',s3);end.

我有原题,是JSOI2010夏令营B层次热身的题B,比较简单,主要是输出格式,程序如下。(保证全对,我满分)
【输出样例】
b.out
125
* 30
-----
0
375
-----
3750
(赋:输出样例,楼主的格式有问题)
程序:
i,l,t:longint;
nn,mm,ss:longint;
n,m,s:string;
begin
readln(nn,mm);
ss:=nn*mm;
str(nn,n);
str(mm,m);
str(ss,s);
l:=length(s)+1;
if length(m)<>1 then
begin
writeln(n:l);
write('*');writeln(m:l-1);
for i:=1 to l do write('-');writeln;
for i:=length(m) downto 1 do
begin
t:=(ord(m[i])-ord('0'))*nn;
writeln(t:l-(length(m)-i));
end;
for i:=1 to l do write('-');writeln;
writeln(ss:l);
end
else
begin
writeln(n:l);
write('*');writeln(m:l-1);
for i:=1 to l do write('-');writeln;
writeln(s:l);
end;
end.

program hu;
const
inf='mul.in';
ouf='mul.out';
var
s1,s,temp:string;
ch:char;
n,code,i,tot,ans:longint;
procedure work(n:longint);
var i:longint;
begin
for i:=1 to n-1 do
write(' ');
end;
begin
assign(input,inf);reset(input);
assign(output,ouf);rewrite(output);
read(n);
read(ch);
readln(s);
str(n,s1);
if length(s1)<length(s)
then
begin
temp:=s1;
s1:=s;
s:=temp;
end;
val(s1,n,code);
writeln(n);
writeln('*',s);
writeln('-----');
for i:=length(s)downto 1 do
begin
work(i);
tot:=0;
case s[i] of
'1':begin writeln(n); inc(tot,n);end;
'2':begin writeln(n*2);inc(tot,n*2);end;
'3':begin writeln(n*3);inc(tot,n*3);end;
'4':begin writeln(n*4);inc(tot,n*4);end;
'5':begin writeln(n*5);inc(tot,n*5);end;
'6':begin writeln(n*6);inc(tot,n*6);end;
'7':begin writeln(n*7);inc(tot,n*7);end;
'8':begin writeln(n*8);inc(tot,n*8);end;
'9':begin writeln(n*9);inc(tot,n*9);end;
end;
if length(s)-i=0
then ans:=ans+tot
else
ans:=ans+tot*(length(s)-i)*10;
end;
writeln('-----');
writeln(ans);
close(input);close(output);
end.
额 代码写的比较猥琐 供大牛bs