qq_落花微夢如雨_03608775
2018-03-20 17:48
case条件选择语句 具体例题
switch-case的简单计算器
#include <stdio.h>
int main( )
{
double a, b;
char op;
scanf("%lf%c%lf", &a, &op, &b);
switch (op)
{
case '+':
printf("%lf + %lf = %lf\n", a, b, a + b);
break;
case '-':
printf("%lf - %lf = %lf\n", a, b, a - b);
break;
case '*':
printf("%lf * %lf = %lf\n", a, b, a * b);
break;
case '/':
if (b != 0)
printf("%lf / %lf = %lf\n", a, b, a / b);
else
printf("除数不能是0! \n");
break;
}
}
C语言入门
926207 学习 · 20797 问题
相似问题