作业帮 > 综合 > 作业

帮忙写一个C语言程序,小学加减法的.

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/09/24 04:18:20
帮忙写一个C语言程序,小学加减法的.
通过计算机随机产生10道加减运算题,两个操作数为1~10之间的随机数,运算类型为随机产生的加、减运算中的一种,如果输入答案正确,则显示“正确!”,否则显示“错误!”,不给机会重做,10道题做完后,按每题10分统计总得分,然后打印出总分和错误题总数.
帮忙写一个C语言程序,小学加减法的.
楼主笑纳,可以在线hi
#include "stdlib.h"
#include "stdio.h"
#include "time.h"
void jiafa(){
int a[10],b[5];
int n,x,y,l=0,t=1;
x=5;
y=10;
srand( (unsigned)time( NULL ) );
for( n = 0; n < 10;n++ )
a[n]=rand()%(y-x+1)+x;
for( n =0; n < 10 ;n+=2)
{
printf("%d. %d+%d=\n",t++,a[n],a[n+1]);
}
printf("please input answers:");
for( n =0; n < 5 ;n++)
scanf("%d",&b[n]);
for( n =0; n < 10 ;n+=2)
{
if(b[n/2]==a[n]+a[n+1])
l++;
}
if(l==5)
printf("Right\n");
else
printf("Error\n");
}
void jianfa(){
int a[10],b[5];
int n,x,y,temp,l=0,t=1;
x=5;
y=10;
srand( (unsigned)time( NULL ) );
for(n=0;n