The largest data type is string
string
Using strings, you can perform addition, subtraction, multiplication and division of 100 to 150 digits or even more
Except for strings
It is impossible to enter numbers with more than 100 digits in any other data type!
But you are also very particular about input and output
After all, strings are different from other data types
I have a high-precision addition here
< p>You can enter any two numbers to addThe length of these two numbers is limited to 150 digits
Not within 150
But 150 Within a number!
var s1,s2:string;
a,b,c:array[0..1000]of integer;{Unit 0 records the length of the number} p>
i,len,jin,t:integer;{jin means carry}
begin
readln(s1);
readln(s2 );
a[0]:=length(s1);
for i:=1 to a[0] do a[i]:=ord(s1[a[ 0]+1-i])-ord('0');
b[0]:=length(s2);
for i:=1 to b[0 ] do b[i]:=ord(s2[b[0]+1-i])-ord('0');{Transfer each number in the string to the array, pay attention to the reverse, so Guaranteed alignment}
if a[0]>b[0] then len:=a[0] else len:=b[0];
jin:=0;< /p>
for i:=1 to len do begin
t:=a[i]+b[i]+jin;
c[i]:= t mod 10;
jin:=t div 10;
end;
if jin>0 then begin
inc(len );
c[len]:=jin;
end;
c[0]:=len;
for i :=c[0] downto 1 do write(c[i]);
writeln;
end.
You can also try ordinary addition Program:
var a,b:int64;
begin
readln(a);
readln(b);
p>writeln(a+b);
end.
int64 must not enter a number consisting of 150 digits!
So string is the largest data type