free pascal中鸡兔同笼问题的程序问题program homework33;var a,b,c,d:byte;begin write('INPUT THE NUMBER OF FEET IS '); READLN(a); write('INPUT THE NUMBER OF HEADS IS '); readln(b); for c:= 0 to b do for b:=0 to b do if 2*c+4*d=a then writeln
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 11:42:21
free pascal中鸡兔同笼问题的程序问题program homework33;var a,b,c,d:byte;begin write('INPUT THE NUMBER OF FEET IS '); READLN(a); write('INPUT THE NUMBER OF HEADS IS '); readln(b); for c:= 0 to b do for b:=0 to b do if 2*c+4*d=a then writeln
free pascal中鸡兔同笼问题的程序问题
program homework33;
var a,b,c,d:byte;
begin
write('INPUT THE NUMBER OF FEET IS ');
READLN(a);
write('INPUT THE NUMBER OF HEADS IS ');
readln(b);
for c:= 0 to b do
for b:=0 to b do
if 2*c+4*d=a
then
writeln('THE NUMBER OF CHICKS IS ',c);
write('THE NUBMER OF RABITS IS ',d);
readln
end.
问题在哪里,为什么算出的结果不对呢?
把程序改了一下
如下
program homework33;
var a,b,c,d:byte;
begin
write('INPUT THE NUMBER OF FEET IS ');
READLN(a);
write('INPUT THE NUMBER OF HEADS IS ');
readln(b);
for c:= 0 to b do
if 2*c+4*(b-c)=a
then
writeln('THE NUMBER OF CHICKS IS ',c);
writeln('THE NUBMER OF RABITS IS ',b-c);
readln
end.
free pascal中鸡兔同笼问题的程序问题program homework33;var a,b,c,d:byte;begin write('INPUT THE NUMBER OF FEET IS '); READLN(a); write('INPUT THE NUMBER OF HEADS IS '); readln(b); for c:= 0 to b do for b:=0 to b do if 2*c+4*d=a then writeln
program homework33;
var a,b,c,d:byte;
begin
write('INPUT THE NUMBER OF FEET IS ');
READLN(a);
write('INPUT THE NUMBER OF HEADS IS ');
readln(b);
for c:= 0 to b do
if 2*c+4*(b-c)=a
then
begin{加上begin,否则第二个语句没有执行}
writeln('THE NUMBER OF CHICKS IS ',c);
writeln('THE NUBMER OF RABITS IS ',b-c);
end;{加上end}
readln
end.