请更正我的代码,如果出口部分正确[关闭]

问题描述 投票:0回答:1

如果输入负数到3个分支,它将终止,如果我输入正数,则继续

#include<stdio.h>
main(){
    float b1,b2,b3;
    int op;
    printf("Branch 1 :");
    scanf("%f", &b1);
    printf("Branch 2 :");
    scanf("%f", &b2);
    printf("Branch 3 :");
    scanf("%f", &b3);

    if(b1>=b2 && b2>=b3 && b3>=b1)
    {
        printf("\n exit");
        break;
    }
    if(b1>=b2 && b1>=b3)
    {
        printf("Branch 1");
    }
    if(b2>=b1 && b2>=b3)
    {
        printf("Branch 2");
    }
    if(b3>=b1 && b3>=b3)
    {
        printf("Branch 3");
    }
    printf("has a highest sales");

    getch();
}

终止输入负继续输入正数

c stdio getch
1个回答
0
投票

[读取浮点数时,您需要将%f传递给scanf而不是%d。

© www.soinside.com 2019 - 2024. All rights reserved.