C语言小学生测验主函数 小学生数学测验系统c语言-成都快上网建站

C语言小学生测验主函数 小学生数学测验系统c语言

C语言问题2: 为小学生设计一个测验简单四则运算的系统

#include stdio.h

创新互联是专业的武乡网站建设公司,武乡接单;提供做网站、网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行武乡网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

#include stdlib.h

#include time.h

#define YES 1

#define NO 0

#define NUM_PROBLEM 10 //题目的数量

#define LIMIT_ADDSUB 100 //加法和减法操作数的上限

#define LIMIT_MULDIV 20 //乘法和除法操作数的上限

int expressionCount = 0;

struct expression

{

int num1;

int num2;

char op;

}expr[NUM_PROBLEM];

int createProblem(void);

int createAddProblem(void);

int createSubProblem(void);

int createMulProblem(void);

int createDivProblem(void);

int expressionExist(int num1, int num2, char op);

int main()

{

int i, answer, result;

float score;

srand((unsigned)time(NULL));

score = 0.0;

for (i = 1; i = NUM_PROBLEM; ++i)

{

printf("第%2d题: ", i);

result = createProblem();

scanf("%d", answer);

getchar();

if (result == answer)

score += 100.0/NUM_PROBLEM;

}

printf("Final Score:%.0f\n", score);

return 0;}

int createProblem(void)

{

char op;

int result;

op = rand()%4+1;

switch (op)

{

case 1: //加法

result = createAddProblem();

break;

case 2: //减法

result = createSubProblem();

break;

case 3: //乘法

result = createMulProblem();

break;

case 4: //除法

result = createDivProblem();

break;

default:

exit(1);

}

return result;}

int createAddProblem(void)

{

int num1, num2;

do

{

num1 = rand()%LIMIT_ADDSUB+1;

num2 = rand()%LIMIT_ADDSUB+1;

} while (expressionExist(num1, num2, '+'));

printf("%3d + %3d = ", num1, num2);

return (num1+num2);}

int createSubProblem(void)

{

int num1, num2, temp;

do

{

num1 = rand()%LIMIT_ADDSUB+1;

num2 = rand()%LIMIT_ADDSUB+1;

if (num1 num2)

{

temp = num1;

num1 = num2;

num2 = temp;

}

} while (expressionExist(num1, num2, '-'));

printf("%3d - %3d = ", num1, num2);

return (num1-num2);}

int createMulProblem(void)

{

int num1, num2;

do

{

num1 = rand()%LIMIT_MULDIV+1;

num2 = rand()%LIMIT_MULDIV+1;

} while (expressionExist(num1, num2, '*'));

printf("%3d * %3d = ", num1, num2);

return (num1*num2);}

int createDivProblem(void)

{

int num1, num2;

do

{

num1 = rand()%LIMIT_MULDIV+1;

num2 = rand()%LIMIT_MULDIV+1;

} while (expressionExist(num1, num2, '/'));

printf("%3d / %3d = ", num1*num2, num1);

return num2;}

int expressionExist(int num1, int num2, char op)

{

int i;

for (i = 0; i expressionCount; ++i)

{

if (expr[i].num1 == num1 expr[i].num2 == num2 expr[i].op == op)

return YES;

}

expr[i].num1 = num1;

expr[i].num2 = num2;

expr[i].op = op;

++expressionCount;

return NO;}

先拿去调试,把问题和需要补充的功能发给我,明天再帮你完善。

c语言小学生测验

#include

#include

#include

int main(){

srand(time(NULL));

int a,b,c,score[10],trueValue,sum=0;

for(int i=0;i10;i++){

for(a=rand()%51,b=rand()%51;a+b50 || a+b50 || a-b0; a=rand()%51,b=rand()%51){;}

c=rand()%3;

for(int j=0;j3;j++){

if(c==1){

printf("%d:%d+%d=",i+1,a,b);

trueValue=a+b;

scanf("%d",score[i]);

if(score[i]!=trueValue){

printf("答案错误,请重新输入.\n");

score[i]=0;

}

else{

if(j==0){

score[i]=10;

}

else if(j==1){

score[i]=7;

}

else{

score[i]=5;

}

break;

}

}

else{

printf("%d:%d-%d=",i+1,a,b);

trueValue=a-b;

scanf("%d",score[i]);

if(score[i]!=trueValue){

printf("答案错误,请重新输入.\n");

score[i]=0;

}

else{

if(j==0){

score[i]=10;

}

else if(j==1){

score[i]=7;

}

else{

score[i]=5;

}

break;

}

}

}

if(score[i]==0){

printf("正确答案是:%d\n",trueValue);

}

sum=sum+score[i];

}

printf("你的成绩是:%d\n",sum);

if(sum90){

printf("SMART.\n");

}

else if(sum=80){

printf("GOOD.\n");

}

else if(sum=70){

printf("OK.\n");

}

else if(sum=60){

printf("PASS.\n");

}

else{

printf("TRYAGAIN\n");

}

return 0;

}

急求:用C语言编写小学生数学测试软件

//vc 6.0调试通过

#includestdio.h

#includestdlib.h

#include time.h

int add(int x,int y)

{return x+y;}

int sub(int x,int y)

{return x-y;}

int mul(int x,int y)

{return x*y;}

void fun(char f)

{

int n,x,y,z,t,result,sum=0;

srand((unsigned)time(NULL));

printf("请选择答题的个数:\n");

scanf("%d",n);

for(int i=0;in;i++)

{

x=rand()%10;

y=rand()%10;

if(xy f=='-')

{t=x;x=y;y=t;}

if(f=='*')

{while(!x){x=rand()%10;}

while(!y){y=rand()%10;}}

printf("%d %c %d =",x,f,y);

scanf("%d",z);

switch(f)

{

case '+':

result=add(x,y);break;

case '-':

result=sub(x,y);break;

case '*':

result=mul(x,y);break;

}

if(result==z)

{printf("正确!\n");sum++;}

else

printf("错误!应该是%d\n",result);

}

printf("\n正确率为%f%%\n/////////////////////////////////\n\n",100.0*sum/n);

fflush(stdin);

}

void main()

{

printf("/////////////////////////////////\n");

printf(" 小学生数学测试软件\n");

printf("//////////////////////////////////\n\n");

char ch;

while(1)

{

printf("请选择题型--加(+),减(-),乘(*),退出(0): ");

ch=getchar();

if(ch=='+'||ch=='-'||ch=='*')

fun(ch);

else if(ch=='0')

exit(0);

else

printf("错误!\n");

}

}

小学生加减乘除测验 c语言代码

#include stdio.h

#include stdlib.h

#include time.h

int ranNum(int a[], int n)

{

int i, j;

srand((unsigned)time(0));

for(i=0;in;i++)

{

a[i]=rand()%26;

for(j=0;ji;j++)

{

if(a[i]=a[j])

{

i--;

break;

}

}

}

return 0;

}

char ranOperator()

{

int k;

srand((unsigned)time());

k=rand()%2;

switch(k)

{

case 0 : return '+'; break;

default : return '-' ; break;

}

}

int main()

{

int i, num1[10], num2[10], input, result, count, score=0, max, min;

char op;

ranNum(num1, 10);

ranNum(num2, 10);

for(i=0;i10;i++)

{

max=num1[i]num2[i]?num1[i]:num2[i];

min=num1[i]num2[i]?num1[i]:num2[i];

op=ranOperator();

switch(op)

{

case '+' : result = max + min; break;

case '-' : result = max - min; break;

}

count=0;

printf("%d %c %d = \n", max, op, min);

while(count++3)

{

input=getchar();

if(input==result)

{

if(count==0)

{

score+=10;

break;

}

else if(count==1)

{

score+=7;

break;

}

else if(count==2)

{

score+=5;

break;

}

}

else

{

printf("计算错误!重新输入!\n");

count++;

}

}

printf("正确答案是%d\n",result);

}

if(score=90)

printf("SMART\n");

else if(score=80)

printf("GOOD\n");

else if(score=70)

printf("OK\n");

else if(score=60)

printf("PASS\n");

else

printf("TRY AGAIN\n");

return 0;

}

c语言:编写函数实现功能,并用相应的主函数进行测试?

#includestdio.h

void delStr(char *s,char p)

{char *p1,*p2;

for(p1=p2=s;*p1;p1++)

if(*p1!=p)*p2++=*p1;

*p2='\0';

}

int main()

{char s[300],ch;

gets(s);

ch=getchar();

delStr(s,ch);

printf("%s\n",s);

return 0;

}


本文名称:C语言小学生测验主函数 小学生数学测验系统c语言
本文链接:http://kswjz.com/article/hgppgi.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流