这个PASCAL程序错在哪里?(入门)

来源:百度知道 编辑:UC知道 时间:2024/04/27 13:47:08
输入一个不大于3位的正整数,输出这个数共有几位,同时输出这个数各个数位上的数字?

显示有一个错误:
0005.txt(12,9) Fatal: Syntax error, ) expected but := found

不知道错在哪里
刚学程序有点乱 请见谅 ;

program wids;
VAR x,a,b,c,q,w,e:integer;
begin
write(' x=');readln(x);
if ((x div 100)=0) then
begin
if ((x div 10)=0) then c:=1
else if ((x div 10)<>0) then c:=2;
end
else if ((x div 100)<>0) then c:=3;
writeln(c);
if (c:=1) then
begin
q:=x div 100;
w:=x div 10-10*q;
e:=x mod 100-10*w;
write(' ',q,' ',w,' ',e);
end
else if (c:=2) then
begin
w:=x div 10;
e:=x mod 10;
write(' ',w,' ',e);
end
else if (c:=1) then
begin
e:=x;
write(' ',e);
end;
end.

c:=1 是赋值语句 不能{if (c:=2) then}(不能做为判断条件)
你这句话的意思就是 {如果c赋值为2 那么} 是不通的
应该改为 {if (c=2) then } ={如果c等于2 那么}

错误提示说你第12行那个c:=1错了,我估计应该改成c=1 因为你是逻辑条件