C语言 switch语句

#include<stdio.h>
int main(){
	float a,c;
	char b;
	printf("please input a+(-,*,/)\n");
	scanf("%f%c%f",&a,&b,&c);
	switch(b){
		case '+':printf("%f",a+c);break;
		case '-':printf("%f",a-c);break;
		case '*':printf("%f",a*c);break;
		case '/':printf("%f",a/c);break;
		default:printf("input error!\a\a\a ");
	}
	return b;
}

 

你可能感兴趣的:(switch)