四則運算計算器

屎臭不怕巷子深發表於2020-12-23
#include<stdio.h>
void main()
{
	float x,y;
	char op;
	scanf("%f%c%f",&x,&op,&y);
	switch(op)
	{
	case'+':
		printf("%.1f%c%.1f=%.1f",x,op,y,x+y);
		break;
	case'-':
		printf("%.1f%c%.1f=%.1f",x,op,y,x-y);
		break;
	case'*':
		printf("%.1f%c%.1f=%.1f",x,op,y,x*y);
		break;
	case'/':
		printf("%.1f%c%.1f=%.1f",x,op,y,x/y);
		break;
	}
}

相關文章