我有一段时间有这个问题。当我尝试运行我的程序时,它会运行,但它会跳过第二个 scanf,即 nudoor,这是我的程序要求门数的部分。
如果有人可以帮忙。这是我的程序运行DOOR SKIP的屏幕截图
int main ()
{
float length, height, width;
height = 7.5;
int nudoor, nuwin, gall, door, win, doorsol, winsol, gallsol, gallsolu;
gall = 450;
door = 18;
win = 9;
printf("Width of Room: ");
scanf("%.2f",&width);
printf("Number of doors: ");
scanf("%d",&nudoor);
printf("Number of windows: ");
scanf("%d",&nuwin);
printf("Length of room: ");
scanf("%.2f",&length);
doorsol = nudoor * door;
winsol = nuwin * win;
gallsol = doorsol + winsol + length + width + height;
gallsolu = gallsol/gall;
if (gall >= gallsol)
printf("Gallons of Paint needed: 0");
else
printf("Gallons of Paint needed:%d",gallsolu);
return 0;
}