编程C语言 连续做十道题,通过计算机随机产生两个1~10之间的加数给学生出一道加法运算题,

作者&投稿:曹周 (若有异议请与网页底部的电邮联系)
c语言小学生加法考试题 ,连续做10道题,通过计算机随机产生两个1~10之间的加数给学生出一道加法运算题程序~

#include #include #include #include void main() {int i,a,b,n,k=0;for(i=1;i<=10;i++){srand((unsigned int)time(0));a=rand()%10+1;b=rand()%10+1;printf("%d+%d=",a,b);scanf("%d",&n);if(n==a+b){printf("Right!
");k++;}else printf("Not correct!
");}printf("总分: %d
做错题的数量: %d",k*10,10-k);getch();}

random()% number
取模

给,已经在VC6上运行确认了:
#include <stdio.h>
#include <stdlib.h> /* 随机库函数 */
#include <time.h> /* 时间库函数 */
int count=0, ok=0; /* count表示回答次数, ok表示回答正确次数 */

/* 加法函数 */
int add(int x,int y)
{
int result = 0;
printf("%d + %d = ",x,y);
scanf("%d",&result);

count++;

if(result==(x+y)) return 1;
else return 0;

}

void print(int flag)
{
if(flag==1) printf("Right!\n");
else printf("Not Correct!\n");
}

void main()
{ int x, y, op, flag=0,i; /* x和y表示两个操作数,op表示操作码,end表示结束标记 */
srand(time(NULL)); /* 随机函数初始化 */

for(i=0;i<10;i++) {
x=1+rand()%10; /* 随机产生1至10的整数 */
y=1+rand()%10; /* 随机产生1至10的整数 */

flag=add(x,y);
print(flag);

if(flag==1) ok++;
}

printf("您总共回答了%d道题,答对%d道题,总得分: %d\n",count,ok,ok*10);
printf("\n");
}


崇文区13891429308: 编程C语言 连续做十道题,通过计算机随机产生两个1~10之间的加数给学生出一道加法运算题, -
阮刷君力: 给,已经在VC6上运行确认了:#include <stdio.h>#include <stdlib.h> /* 随机库函数 */#include <time.h> /* 时间库函数 */ int count=0, ok=0; /* count表示回答次数, ok表示回答正确次数 *//* 加法函数 */ int add(int x,int y) { int result = 0; printf("%d + ...

崇文区13891429308: C语言设计一个运算10道题的程序
阮刷君力: #include &lt;stdio.h&gt; void check(double correct_answer[],double answer[],char question[10][100]) { int i,score=0; for(i=0;i&lt;10;i++) if(answer[i]!=correct_answer[i]) printf("第%d题“%s”:答案错误,正确答案应为:%.1Lf\n",i+1,question[i],...

崇文区13891429308: c语言求教 编程实现10道+, - ,*,/的运算 -
阮刷君力: int a = 1; int b = 2; int c ; c= a+b; c = a* b; c = a-b; c = a/b; c = a+b/a; c = a+b*a; c = a- b/a; c = a-b*a; c = b + a/b; c = b - a/b;

崇文区13891429308: 用C语言 给小学生出加法考试题 -
阮刷君力: #include int AddTest(int a,int b) { int answer; printf("Please input the answer:"); scanf("%d",&answer); if(answer==a+b){ printf("Right!\n"); return 1;} else{ printf("Not correct!\n"); return 0;} } int main() { int i,j,k,m,sum=0,wsum=10; for(k=0;k i ...

崇文区13891429308: 编程实现10道+, - ,*,/的运算(c语言) -
阮刷君力: #include<stdio.h>#include<ctype.h>#include<math.h> void f2() { int i=1,t=1,a; scanf("%d",&a); while(i<=a) { t*=i; i++; } printf("!=%d",t); } void main() { int a,b; char d; do { printf("input expression: a+(-,*,/,^,s,!)b\n"); scanf("%d %d",&a,&b); ...

崇文区13891429308: 实现一个二十以内的加、减、乘、除10道计算机练习测试的程序 C语言!!! -
阮刷君力: #include void main() { int i,a,b,c,d,an,s; char ch[4]={'+','-','*','/'}; srand( (unsigned)time(NULL));i=0; s=0;a=rand()%21;b=rand()%21;while(i {c=rand()%4; switch(c) {case 0:while((a=rand()%21)+(b=rand()%21)>20);break; case 1:while((a=rand()%21)-(...

崇文区13891429308: C语言连续出十道随机算数,用户做答,统计用户回答问题情况 -
阮刷君力: 用random()取随机数.random()%4,来随机选一个 + - * / random()%100 取两个100以内的数字 然后让用户输入的答案与计算机计算的答案对比,统计.

崇文区13891429308: 实现一个20以内的加减乘除10道计算机练习测试,用c语言程序 -
阮刷君力: #include <stdlib.h>#include <iostream.h>#include <conio.h>#include <time.h> int main() { int a = 0; int b = 0; int mode = 0;//0:加 1:减 2:乘 3:除 int c = 0; int result = 0; int score = 0; int i = 0; srand((unsigned)time( NULL ) ); //初始化随机数发生...

崇文区13891429308: C语言编程:随机出10道100以内的整数加减法算术题. -
阮刷君力: #include <stdio.h> #include <stdlib.h> int main() { int a,i,j; for(a=0;a<10;a++) { i = 100.0*rand()/(RAND_MAX+1.0); j = 100.0*rand()/(RAND_MAX+1.0); printf("%d + %d = \n",i,j); } }

崇文区13891429308: 1.编写C语言函数,实现20以内的加、减、乘、除(整除)运算10道题. -
阮刷君力: #include #include int main() { int a = 0; int b = 0; int mode = 0;//0:加 1:减 2:乘 3:除 int c = 0; int result = 0; int score = 0; int i = 0; srand((unsigned)time( NULL ) ); //初始化随机数发生器,使得每次运行生成的随机数不同 for(i=0;i{ a = rand() % ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网