企业400电话办理用途:pascal编程(1)两个高精度的减法(2)多位高精度与一位数的乘法。
Const
MaxN=225;
Type
NType=Array[1..MaxN]Of Integer;
Var
Len:Byte;
A,B,C:NType;
Procedure Origin;
Var
I,TempLen:Byte;
TempString:String;
Begin
Len:=0;
Fillchar(A,Sizeof(A),0);
Readln(TempString);
TempLen:=Length(TempString);
If TempLen>Len Then
Len:=TempLen;
For I:=0 To TempLen-1 Do
A[MaxN-I]:=Ord(TempString[TempLen-I])-48;
Fillchar(B,Sizeof(B),0);
Readln(TempString);
TempLen:=Length(TempString);
If TempLen>Len Then
Len:=TempLen;
For I:=0 To TempLen-1 Do
B[MaxN-I]:=Ord(TempString[TempLen-I])-48;
End;
Procedure Lend(I:Byte);
Begin
If A[I]<=0 Then
Lend(I-1);
Dec(A[I]);
A[I+1]:=A[I+1]+10;
End;
Procedure Main;
Var
I:Byte;
Begin
For I:=MaxN Downto MaxN-Len+1 Do
Begin
If A[I]<B[I] Then
Lend(I-1);
C[I]:=A[I]-B[I];
End;
End;
Procedure PrintOut;
Var
I:Byte;
Begin
If C[MaxN-Len+1]>0 Then
Write(C[MaxN-Len+1]);
For I:=MaxN-Len+2 To MaxN Do
Write(C[I]);
Writeln;
End;
Begin
Origin;
Main;
PrintOut;
End.
Const
MaxN=225;
Type
NType=Array[1..MaxN]Of Integer;
Var
Len,B:Byte;
A,C:NType;
Procedure Origin;
Var
I,TempLen:Byte;
TempString:String;
Begin
Len:=0;
Fillchar(A,Sizeof(A),0);
Readln(TempString);
TempLen:=Length(TempString);
Len:=TempLen+1;
For I:=0 To TempLen-1 Do
A[MaxN-I]:=Ord(TempString[TempLen-I])-48;
Readln(B);
End;
Procedure Main;
Var
I,Over:Byte;
Begin
Over:=0;
For I:=MaxN Downto MaxN-Len+1 Do
Begin
Over:=A[I]*B+Over;
C[I]:=Over Mod 10;
Over:=Over Div 10;
End;
End;
Procedure PrintOut;
Var
I:Byte;
Begin
If C[MaxN-Len+1]>0 Then
Write(C[MaxN-Len+1]);
For I:=MaxN-Len+2 To MaxN Do
Write(C[I]);
Writeln;
End;
Begin
Origin;
Main;
PrintOut;
End.
累死了。。。给点钱吧。。。呵呵。。。