为什么我的程序跳过第二个 scanf 行?

Why is my program skipping the 2nd scanf line?

这个问题我有一段时间了。当我尝试 运行 我的程序时,它会 运行 但它会跳过第二次 scanf,这是 nudoor,我的程序要求门数的部分。

如果有人能帮忙。这是我的程序的截图 运行ning 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;
}

格式字符串如下图

scanf("%.2f",&width);

不正确。 scanf 的格式字符串没有精度部分 .2(与 printf 相反)。因此,在用于读取浮点数的所有地方都将其删除。