编了个程序来解决
1 var a,b,c,d,i,sum1,sum2,sum3,sum4:longint; 2 begin 3 sum1:=0; 4 for i:=1 to 9 do inc(sum1,i); 5 writeln(sum1); 6 sum2:=0; 7 for i:=10 to 99 do begin 8 a:=i div 10; 9 b:=i mod 10; 10 sum2:=sum2+a+b; 11 end; 12 writeln(sum2); 13 sum3:=0; 14 for i:=100 to 999 do begin 15 a:=i div 100; 16 b:=i div 10 mod 10; 17 c:=i mod 10; 18 sum3:=sum3+a+b+c; 19 end; 20 writeln(sum3); 21 sum4:=0; 22 for i:=1000 to 1500 do begin 23 a:=i div 1000; 24 b:=i div 100 mod 10; 25 c:=i div 10 mod 10; 26 d:=i mod 10; 27 sum4:=sum4+a+b+c+d; 28 end; 29 writeln(sum4); 30 writeln(sum1+sum2+sum3+sum4); 31 end.