#include<stdio.h>intmain(void){char choice,ch;float firstnum,secondnum;int go=1;while(go){printf("Enter the operation of your choice:\n");printf("a. add s.substract\n");printf("m.multiply d.divide\n");printf("q.quit\n");fflush(stdin);
choice=getchar();while(getchar()!='\n')continue;printf("您的选择为%c\n",choice);if(choice!='q'){printf("Enter first number:");while(scanf("%f",&firstnum)!=1){while((ch=getchar())!='\n')continue;putchar(ch);printf("is not an number.\nPlease enter a number,such as 2.3,-1.78E8,or 3:");}printf("Enter second number:");while(scanf("%f",&secondnum)!=1){while((ch=getchar())!='\n')continue;putchar(ch);printf("is not an number.\nPlease enter a number,such as 2.3,-1.78E8,or 3:");}}switch(choice){case'a':printf("%f+%f=%f\n",firstnum,secondnum,firstnum+secondnum);continue;case's':printf("%f-%f=%f\n",firstnum,secondnum,firstnum-secondnum);continue;case'm':printf("%f*%f=%f\n",firstnum,secondnum,firstnum*secondnum);continue;case'd':while(secondnum==0){printf("Enter a number other than 0:");scanf("%f",&secondnum);}printf("%f/%f=%f\n",firstnum,secondnum,firstnum/secondnum);continue;case'q':printf("Bye.");
go=0;break;}}}