Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何解决错误:开关量不是整数,错误:案例标签没有减少为整数常量;_C - Fatal编程技术网

C 如何解决错误:开关量不是整数,错误:案例标签没有减少为整数常量;

C 如何解决错误:开关量不是整数,错误:案例标签没有减少为整数常量;,c,C,我正在使用C语言制作一个程序,该程序根据项目团队中的员工在各种标准(如MVP)中获得的平均分来选择他们,因此得到的错误出现在switch语句中,该语句表示error:switch quantity不是整数,第二个错误是error:case-label没有减少到整数常量 代码如下: #include <stdio.h> main() { printf("Google Team Selection\n\n"); double a, b, c, sum

我正在使用C语言制作一个程序,该程序根据项目团队中的员工在各种标准(如MVP)中获得的平均分来选择他们,因此得到的错误出现在
switch
语句中,该语句表示
error:switch quantity不是整数,第二个错误是
error:case-label没有减少到整数常量

代码如下:

#include <stdio.h>

main() {
    printf("Google Team Selection\n\n");
    double a, b, c, sum, average;
    printf("Enter your Minimum Viable Product(MVP) points here:\n");
    scanf("%lf", &a);
    printf("Enter your Apprenticer Programmer points here:\n");
    scanf("%lf", &b);
    printf("Enter your consistency points here:\n");
    scanf("%lf", &c);
    printf("Enter your qocient points");
    sum = a + b + c;
    average = sum / 3.0;
    printf(" the sum is %lf and the average is %lf", sum, average);
    switch (average) {
      case ">55":
        printf("Congratulations you have been selected\n");
        break;
    }
}
#包括
main(){
printf(“谷歌团队选择\n\n”);
双a、b、c、总和、平均值;
printf(“在此处输入您的最低可行产品(MVP)点数:\n”);
scanf(“%lf”、&a);
printf(“在此处输入学徒程序员点数:\n”);
scanf(“%lf”、&b);
printf(“在此处输入一致性点:\n”);
scanf(“%lf”、&c);
printf(“输入您的质量分数”);
总和=a+b+c;
平均值=总和/3.0;
printf(“总和为%lf,平均值为%lf”,总和,平均值);
交换机(平均){
案例“>55”:
printf(“祝贺您被选中\n”);
打破
}
}

因此,我希望我的程序选择平均值高于
55

的员工。开关需要一个整数、一个字符或一个输出为int或char的表达式。这个案例也需要一个常量表达式。你可以查一下电话号码

在这种情况下,您应该使用if-else

因此:


不能在C中使用
switch
:switch表达式(
average
)和
case
表达式必须是整数

您应该使用一个简单的
if
语句:

    if (average > 55) {
        printf("Congratulations you have been selected\n");
    }

抱歉,但这与StrongLoop有什么关系?根据标签描述:“StrongLoop是一个API层,用于将企业数据连接到设备和浏览器。它包括LoopBackJS、StrongOps和StrongNode。”任何一本像样的书/教程都可以回答,或者重复一些关于switch语句中的范围/更大/更小的问题,例如:。
    if (average > 55) {
        printf("Congratulations you have been selected\n");
    }