小编Sch*_*lky的帖子

在C中循环.程序中的第一个循环不起作用并且是无限的

我不明白为什么第一个循环不起作用.即使填充的欠款浮动实际上大于0,它也是一个无限循环.为什么循环不起作用?

#import <cs50.h> 
#import <stdio.h>

int main(void)
{
    float owed = -1 ;

    while (owed < 0) 
    {
        printf("O hai! How much change is owed?\n") ;
        float owed = GetFloat() ;
        owed = owed * 100 ;
    }

    int coins = 0 ;

    while (owed >= 25)
    {
        owed = owed - 25 ;
        coins = coins + 1 ;
    }

    while (owed >= 10)
    {
        owed = owed - 10 ;
        coins = coins + 1 ;
    }

    while …
Run Code Online (Sandbox Code Playgroud)

c loops cs50

-3
推荐指数
1
解决办法
63
查看次数

标签 统计

c ×1

cs50 ×1

loops ×1