罪滅ぼしに、ちょっとヒントを。
var next:boolean;
...
next:=true;
while next do
begin
入力
if a=0 then next:=false;
その他のチェック
end;