计算机 函数 小学生 听得懂,给小学生编写练习20以内加,减法计算的程序

#include

#include

int mark=0,number=0,right=0,wrong=0,x;

put_out(char k)

{

int a,b,c,x,flag=1;

if(k=='+')

{

while(flag==1)

{

a=srand(21);

b=random(21);

c=a+b;

if(c=0)

{

flag=0;

printf("%d-%d=",a,b);

}

}

x=a-b;

}

return(x);

}

int judge_answer(int answer,int x)

{

int a;

printf("\nPlease put in your answer:");

scanf("%d",&answer);

if(answer==x)

{

printf("\nthat is right!");

right++;

mark=right*10;

printf("\nyour mark is %d\n",mark);

}

else

{

wrong++;

printf("\nthat is not correct!");

printf("\nyour mark is %d\n",mark);

}

a=answer;

return(a);

}

void result()

{

printf("you have complete %d problems!\nRight number:%d!\nWrong number:%d!\nand your score is:%d!",number,right,wrong,mark);

}

void main()

{

int j,answer;

char k,e;

printf("please choose the aigorithm:('+'or'-')");

scanf("%s",&k);

for(number=0;number5)

{

printf("exit or not (Y/N)?");

getchar();

e=getchar();

}

if(e=='y'||e=='Y')

break;

}

result();

}。

全部

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值