方法一、(DELPHI下调试通过)
program test; {$apptype console}
uses sysutils;
var x,y,z,i: integer;
begin
x:=123;
y:=456;
val(inttostr(x)+inttostr(y),z,i);
writeln(z);
end.
方法二、(几乎所有PASCAL通用)
program test; {$apptype console}
var x,y,z: integer;
begin
x:=123;
y:=456;
if y>10000 then z:=x*100000+y
else if y>1000 then z:=x*10000+y
else if y>100 then z:=x*1000+y
else if y>10 then z:=x*100+y
else z:=x*10+y;
writeln(z);
end.
把123和456都转化成字符串
再把两个字符串连起来
再把连起来后的字符串转成数值型
very easy
第一种方法:
var c:integer;
begin
c:=123*1000+456;
end;
另一种方法:
var c:string;number,co:integer;
begin
c:='123'+'456';
val(c,number,co);
end.
以上程序中c为结果
太简单的,
begin
writeln('123456');
readln;
end.
var
a,b,c:string;
begin
readln(a);
readln(b);
c:=a+b;
writeln(c);
end.
a:=123;
b:=456;
c:=a*1000+b;
writeln(c);