int number_jia(int a,int b);
int number_jian(int a,int b);
int number_cheng(int a,int b);
int number_chu(int a,int b);
int suijishu();
int main()
{
int count;
int yunsuan=1;
int i;
char yunsuanfu[4]={'+','-','*','/'};
int num1=1,num2=1;
int input_result;
int score=0;
int (*pfun[4])(int,int)={number_jia,number_jian,number_cheng,number_chu};
char jixu='y';
while(1)
{
if(tolower(jixu)!='y')
break;
printf("输入题目数量
");
scanf("%d",&count);
printf("选择要进行的运算 1:加法 2:减法 3:乘法 4:除法
");
scanf("%d",&yunsuan);
yunsuan<=4?yunsuan:1;
for(i=0;i<count;i++)
{
num1=suijishu();
num2=suijishu();
printf("
%d%c%d=",num1,yunsuanfu[yunsuan-1],num2);
scanf("%d",&input_result);
if(input_result==(pfun[yunsuan-1])(num1,num2))
score+=2;
}
printf("%s你好你一共得分%d ",score);
printf("是否继续 y:继续");
scanf(" %c",&jixu);
}
return 0;
}
int suijishu()
{
srand(time(NULL)-1);
return rand()%100;
}
int number_jia(int a,int b)
{
return a+b;
}
int number_jian(int a,int b)
{
return a-b;
}
int number_cheng(int a,int b)
{
return a*b;
}
int number_chu(int a,int b)
{
if(b!=0)
return a+b;
else
return 0;
}