main()
{int a,b,num;
printf("1.+\n2.-\n3.*\n4./\n5.exit\n");
do
{printf("\nplease choose a number(1-5):\n");
scanf("%d",&num);
switch(num)
{case 1:printf("please input a and b:\n");
scanf("%d%d",&a,&b);
printf("%d+%d=%d\n",a,b,a+b);
case 2:printf("please input a and b:\n");
scanf("%d%d",&a,&b);
printf("%d-%d=%d\n",a,b,a-b);
case 3:printf("please input a and b:\n");
scanf("%d%d",&a,&b);
printf("%d*%d=%d\n",a,b,a*b);
case 4:printf("please input a and b:\n");
scanf("%d%d",&a,&b);
printf("%d/%d=%f\n",a,b,(float)a/b);
default:printf("error!\n");
}
}while(num!=5);
}
主要功能:能够利用+ - x / 运算的一个类似计算器
设计思想:以+ - x /的运算规律为核心来一步一步推理
总结:通过这次四则运算的作业,从同学那里帮助很多,有些之前学习之后的漏洞也有所弥补,还需继续学习!