我已经尝试了很多次,但我无法弄清楚有什么问题!请帮我解决这个错误。我在这里做错了什么?
#include <`stdio.h>
int main(void)
{
float accum = 0, number = 0;
char oper;
printf("\nHello. This is a simple 'printing' calculator. Simply enter the number followed");
printf(" by the operator that you wish to use. ");
printf("It is possible to use the standard \noperators (+, -, *, /) as well as two extra ");
printf("operators:\n");
printf("1) S, which sets the accumulator; and\n");
printf("2) N, that ends the calculation (N.B. Must place a zero before N). \n");
do
{
printf("\nPlease enter a number and an operator: ");
scanf("%f %c", &number, &oper);
if (number == 0 && oper == 'N')
{
printf("Total = %f", accum);
printf("\nEnd of calculations.");
}
else if (oper == '+', '-', '*', '/', 'S')
{
switch (oper)
{
case 'S':
accum = number;
printf("= %f", accum);
break;
case '+':
accum = accum + number;
printf("= %f", accum);
break;
case '-':
accum = accum - number;
printf("= %f", accum);
break;
case '*':
accum = accum * number;
printf("= %f", accum);
break;
case '/':
if (number != 0)
{
accum = accum/number;
printf("= %f", accum);
}
else
printf("Cannot divide by zero.");
break;
default:
printf("Error. Please ensure you enter a correct number and operator.");
break;
}
}
else
printf("Error. Please ensure you enter a correct number and operator.");
}
while (oper != 'N');
return 0;
}
当我编译这段代码时,我在这里得到如下快照图像的错误。 snapshot of error message
检查的第一行的#include <'stdio.h> – artm
请复制粘贴的编译器的输出,使用图像的文字是很烦人的,脆(我不能像访问由于一些重定向失败)。 – unwind
'=='运算符不是一个不重要的'any_of_these()'函数。 'if(oper =='+',' - ','*','/','S')'是错误的,你可以**将它重写为'if(oper =='+'|| oper ==' - '|| oper =='*')'但是因为你已经有一个'switch'构造,你可以放弃这个''default'块。请注意,您的错误消息_“错误,请确保您输入...”实际上从未显示过...... –