c语言随机产生运算类型6,求大神编一个C语言的题———[题目描述]随机产生1-10之间的随机正整数,进行四则运算,在屏幕上产生算式:6*7=?若正...

#include "stdio.h"

#include "stdlib.h"

#include "time.h"

int main()

{

x09int i,j,a,b,c,ans,ans1,score=0;

x09float ans2;

x09for(i=0;i<10;i++)

x09{

x09x09srand(time(0));

x09x09a=rand()%9+1;

x09x09b=rand()%9+1;

x09x09c=rand()%3;

x09x09switch(c)

x09x09{

x09x09case 0:

x09x09x09ans=a+b;

x09x09x09printf("%d+%d=?n",a,b);

x09x09x09scanf("%d",&ans1);

x09x09x09for(j=0;j<2;j++)

x09x09x09{

x09x09x09x09if(ans1==ans)

x09x09x09x09{

x09x09x09x09x09score+=10;

x09x09x09x09x09printf("Good!n");

x09x09x09x09x09break;

x09x09x09x09}

x09x09x09x09else

x09x09x09x09{

x09x09x09x09x09printf("Wrong,Try Again!n");

x09x09x09x09x09scanf("%d",&ans1);

x09x09x09x09}

x09x09x09}

x09x09x09break;

x09x09case 1:

x09x09x09ans=a-b;

x09x09x09printf("%d-%d=?n",a,b);

x09x09x09scanf("%d",&ans1);

x09x09x09for(j=0;j<2;j++)

x09x09x09{

x09x09x09x09if(ans1==ans)

x09x09x09x09{

x09x09x09x09x09score+=10;

x09x09x09x09x09printf("Good!n");

x09x09x09x09x09break;

x09x09x09x09}

x09x09x09x09else

x09x09x09x09{

x09x09x09x09x09printf("Wrong,Try Again!n");

x09x09x09x09x09scanf("%d",&ans1);

x09x09x09x09}

x09x09x09}

x09x09x09break;

x09x09case 2:

x09x09x09ans=a*b;

x09x09x09printf("%d*%d=?n",a,b);

x09x09x09scanf("%d",&ans1);

x09x09x09for(j=0;j<2;j++)

x09x09x09{

x09x09x09x09if(ans1==ans)

x09x09x09x09{

x09x09x09x09x09score+=10;

x09x09x09x09x09printf("Good!n");

x09x09x09x09x09break;

x09x09x09x09}

x09x09x09x09else

x09x09x09x09{

x09x09x09x09x09printf("Wrong,Try Again!n");

x09x09x09x09x09scanf("%d",&ans1);

x09x09x09x09}

x09x09x09}

x09x09x09break;

x09x09case 3:

x09x09x09ans2=(float)a/b;

x09x09x09printf("%d/%d=?n",a,b);

x09x09x09scanf("%d",&ans1);

x09x09x09for(j=0;j<2;j++)

x09x09x09{

x09x09x09x09if(ans1==ans2)

x09x09x09x09{

x09x09x09x09x09score+=10;

x09x09x09x09x09printf("Good!n");

x09x09x09x09x09break;

x09x09x09x09}

x09x09x09x09else

x09x09x09x09{

x09x09x09x09x09printf("Wrong,Try Again!n");

x09x09x09x09x09scanf("%d",&ans1);

x09x09x09x09}

x09x09x09}

x09x09x09break;

x09x09}

x09}

x09printf("您的成绩是:%dn",score);

x09return 0;

}

运行结果:

71503c1eabe225e40258a90fd33860ed.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值