c - 错误消息 "Expression must have integral or unscoped enum type"

标签 c visual-studio-2017

代码:

    int a1, b1, c1, a2, b2, c2;

    printf("This is the program to help you solve \n First Degree In Two Variable Equation \n");

    printf("The standard of \n First Degree In Two Variable Equation is follow: "
        " \n a1 * x + b1 * y = c1\n a2 * x + b2 * y = c2  ");

    printf("Please enter a1");
    scanf("%d", &a1);

    printf("Please enter b1");
    scanf("%d", &b1);

    printf("Please enter c1");
    scanf("%d", &c1);

    printf("Please enter a2");
    scanf("%d", &a2);

    printf("Please enter b2");
    scanf("%d", &b2);

    printf("Please enter c2");
    scanf("%d", &c2);
    if (a1 * b2 == a2 * b1)
        printf("Coefficient's VALUE ARE NOT ALLOW please enter again");
    else
    {
        double x = (double)(b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
        double y = (double)(a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1);
        printf(" x = " + x + "\n y = " + y);
    }
    return 0;
}

尝试将此代码放在您的 Visual Studio 上,您将在代码末尾看到 printf("x = "+ * x * + "\n y = "+ y);您可以看到 x 我使用 * 来阻止显示错误消息 表达式必须具有整数或无范围枚举类型! 我该如何修复它

最佳答案

尝试下面的代码:

int a1, b1, c1, a2, b2, c2;

printf("This is the program to help you solve \n First Degree In Two Variable Equation \n");

printf("The standard of \n First Degree In Two Variable Equation is followed: "
    " \n a1 * x + b1 * y = c1\n a2 * x + b2 * y = c2  ");

printf("Please enter a1");
scanf("%d", &a1);

printf("Please enter b1");
scanf("%d", &b1);

printf("Please enter c1");
scanf("%d", &c1);

printf("Please enter a2");
scanf("%d", &a2);

printf("Please enter b2");
scanf("%d", &b2);

printf("Please enter c2");
scanf("%d", &c2);
if (a1 * b2 == a2 * b1)
    printf("Coefficient's VALUE ARE NOT ALLOW please enter again");
else
{
    double x = (double)(b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
    double y = (double)(a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1);
    printf(" x = %f\ny = %f\n", x, y);
}
return 0;
}

关于c - 错误消息 "Expression must have integral or unscoped enum type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46138486/

相关文章:

c++ - 使用嵌套类时不完整/未定义的类型

c - 为什么 PSTR 类型在不同的 visual studio 项目类型上有不同的行为?

c - 尝试将地址传递给简单变量到 C 中的函数(指针和循环)

c - 多线程中的数组迭代

git - 为什么 "Compare with Unmodified"在 Visual Studio 2017 中不起作用?

c++ - 运行 MFC 应用程序时有没有办法输出到 "console"?

c - char 数组声明形式之间的区别

c - 如何找出库中缺少的函数,但哪些函数存在于与库一起发布的公开头文件中?

c++ - 在 C++ 中调用 delete/delete[] 时中断调试器

visual-studio-2015 - "Unable to connect to web server ' IIS Express '"