。你真是,我服了你了。你一定初中数学没有学好。 if (用户输入的数字 < 10) and (用户输入的数字 > 0) then 证明有一个数字 else if (用户输入的数字 > 10) and (用户输入的数字 < 100) then 证明有两个数字 else if (用户输入的数字 > 100) and (用户输入的数字 < 1000) then 证明有三个数字 else if (用户输入的数字 > 1000) and (用户输入的数字 < 10000) then 证明有四个数字 else if (用户输入的数字 > 10000) and (用户输入的数字 <100000) then 证明有五个数字 else 证明大于五位数字或者小于0
n为所给正整数 var m : integer; m := 1;//纪录位数 while n > 0 do begin case n of 1..9: print n else begin print (n mod 10); m := m + 1 n := n div 10; end; end;
var num,tmp,i:integer; begin i=0; write('input a number:'); readln(num); tmp=num; while tmp>0 do begin writeln(tmp mod 10); tmp=tmp div 10; i=i+1 end; writeln('total :'i); end.
if (用户输入的数字 < 10) and (用户输入的数字 > 0) then
证明有一个数字
else if (用户输入的数字 > 10) and (用户输入的数字 < 100) then
证明有两个数字
else if (用户输入的数字 > 100) and (用户输入的数字 < 1000) then
证明有三个数字
else if (用户输入的数字 > 1000) and (用户输入的数字 < 10000) then
证明有四个数字
else if (用户输入的数字 > 10000) and (用户输入的数字 <100000) then
证明有五个数字
else
证明大于五位数字或者小于0
var m : integer;
m := 1;//纪录位数
while n > 0 do
begin
case n of
1..9: print n
else
begin
print (n mod 10);
m := m + 1
n := n div 10;
end;
end;
num,tmp,i:integer;
begin
i=0;
write('input a number:');
readln(num);
tmp=num;
while tmp>0 do
begin
writeln(tmp mod 10);
tmp=tmp div 10;
i=i+1
end;
writeln('total :'i);
end.
mm只学到if ,case语句,
其它控制语句还没学到 :(
只能用最原始的方法.结合二楼和mod才能搞定.