c语言,挑选加法或减法进行运算,帮我看一下哪里错了……
#include<stdio.h>#include<stdlib.h>intmain(void){charsymbol;printf("pleasechooseamath...
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char symbol;
printf("please choose a mathematical symbol +\- :");
symbol=getchar();
float x,y;
scanf("%c",&symbol);
printf("please input two numbers:");
scanf("%f %f",&x,&y);
if (symbol==43)
printf("%f+%f=%f",x,y,x+y);
else
if (symbol==45)
printf("%f-%f=%f",x,y,x-y);
else
printf("please choose the right symbol");
system("pause");
return 0;
}
运行时只显示最后一个…… 展开
#include <stdlib.h>
int main(void)
{
char symbol;
printf("please choose a mathematical symbol +\- :");
symbol=getchar();
float x,y;
scanf("%c",&symbol);
printf("please input two numbers:");
scanf("%f %f",&x,&y);
if (symbol==43)
printf("%f+%f=%f",x,y,x+y);
else
if (symbol==45)
printf("%f-%f=%f",x,y,x-y);
else
printf("please choose the right symbol");
system("pause");
return 0;
}
运行时只显示最后一个…… 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询