试着写简单计算器的代码,但很多不会
#include <stdio.h>#include <math.h>
int main() {
int z,i,j;
while (1) {
printf(" *********************\n");
printf(" ** 1.加法运算 **\n");
printf(" ** 2.减法运算 **\n");
printf(" ** 3.乘法运算 **\n");
printf(" ** 4.除法运算 **\n");
printf(" ** 5.求余运算 **\n");
printf(" ** 6.累加运算 **\n");
printf(" ** 7.阶乘运算 **\n");
printf(" ** 8.退出 **\n");
printf(" *********************\n");
printf(" 请选择功能:");
scanf("%d",&z);
printf("请输入操作数:");
scanf("%d%c%d",&i,&j);
switch(z) {
case 1:printf("=%d",i+j);break;
case 2:printf("=%d",i-j);break;
case 3:printf("=%d",i*j);break;
case 4:
if(j==0)
{printf("分母不能为零"); break; }
printf("=%d",i/j);break;
default:printf("无解");break;
case 5:printf("=%d",i%j);break;
}
}
}