代码:
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 * +" \ ny =" + y );你可以看到x我用*来阻止显示错误信息Expression必须有整数或无范围的枚举类型! 我该如何解决?
答案 0 :(得分:1)
尝试以下代码:
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;
}