❶ c语言小学生测试答题部分怎么写:电脑随机出10道题,每题10分,给3次机会,第一次程序结束时显示学生得分
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int a,b,answer,right=0, wrong=0;
int i=1;
srand(time(NULL));
while(i<=10)
{
a=rand()%100+1;
b=rand()%100+1;
printf("%d+%d=",a,b);
scanf("%d",&answer);
if(answer==a+b)
{
printf("正确\n");
++right;
}
else
{
printf("错误\n");
++wrong;
}
i++;
if(wrong==3)
break;
}
printf("你答对%d题得到%d分,答错%d题\n",right,right*10,wrong);
}
❷ 急啊~~~用C语言做一个小学生二位数加法测试程序
#include<stdio.h>
#include<stdlib.h>
int main(){
int a,b,c,seed;
while(1){
seed=rand();
srand(seed);
a=rand()%100;
b=rand()%100;
printf("%d + %d =\n",a,b);
scanf("%d",&c);
if(a+b==c)
printf("正确\n");
else printf("错误\n");
}
return 0;
}
❸ c语言做 小学生算术运算测试系统。vc++6.0
我这儿有个和1相关的,私信我,发给你
❹ C语言程序设计 小学生测验
你好!
· 小涵系列1108 的回答很细了,自己修改一下程序吧,有问题私信联系
❺ c语言小学生测验
#include
#include
#include
int main(){
srand(time(NULL));
int a,b,c,score[10],trueValue,sum=0;
for(int i=0;i<10;i++){
for(a=rand()%51,b=rand()%51;a+b>50 || a+b50 || a-b<0; a=rand()%51,b=rand()%51){;}
c=rand()%3;
for(int j=0;j<3;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(sum>90){
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语言写一个 小学生口算出题系统
一、设计的流程:
1. 主界面设计,选择练习或测试,按ESC结束程序。
2. 题型选择界面设计,选择加、减、乘、除或混合运算,按ESC返回主界面。
3. 系统随机出题,运算数及结果均在100以内,乘、除法应能整除,显示算式。
4. 练习时,系统随机出题,键入结果,正确和错误均有提示,出错时允许再输入,最多三次机会,若还不正确,给出答案。继续出题,按ESC,显示总题数,正确数和正确率。
5. 测试时,系统自动出10道题,每题只给一次机会,每题10分,统计得分。结束后,给出总分,显示各题的对错信息,错误的给出答案。中间按ESC键结束。显示已作题的对错信息,错误的给出答案,不显示得分,按任意键返回题型选择界面。
相关知识:按键操作、数组、指针、结构体等
二、例程:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
voidmain()
{
inta[10],b[10],d[10],c[10],num=0,result,add=0;
floatval;
charfa[5]={'+','-','*','/'};
/*出10道题*/
while(1)
{
srand((unsigned)time(NULL));
d[num]=abs(rand())%4;/*保证出题算法的随机性*/
while(1)/*保证出题成功*/
{
c[num]=-1;
a[num]=abs(rand())%100;
b[num]=abs(rand())%100;
if(d[num]==0)c[num]=a[num]+b[num];
elseif(d[num]==1)c[num]=a[num]-b[num];
elseif(d[num]==2)c[num]=a[num]*b[num];
elseif(d[num]==3)
{
if(b[num]>0)val=1.0*a[num]/b[num];
elseval=-1;
}
if(d[num]<=2)
{
if(c[num]>=0&&c[num]<=100)break;
}
else
{
if(a[num]==int(val)*b[num]&&val>=0)
{c[num]=val;break;}
}
}
num++;
if(num==10)break;
}
/*回答*/
num=0;
while(1)
{
printf("%d%c%d=",a[num],fa[d[num]],b[num]);
scanf("%d",&result);
if(result==c[num])
{
printf("回答正确! ");
add+=10;
}
else
printf("错误,正确答案:%d ",c[num]);
num++;
if(num==10)break;
}
printf(" 得分:%d ",add);
getch();
}
❼ C语言程序设计:小学生测验
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int num=0,err=0; /* 答题数,错误数 */
while(1)
{
int a=0,b=0,d=0,c=0,i=0,result;
char sf[2]={'+','-'};
/* 出题 */
while(1)
{
a=rand()%51;
b=rand()%51;
d=rand()%2;
if(d==0)c=a+b;
else c=a-b;
if(c>=0 && c<=50)break;
}
printf("%d %c %d = \n",a,sf[d],b);
/* 回答 */
printf("输入计算结果:\n");
while(1)
{
scanf("%d",&result);
i++;
if(result==c)
{
printf("回答正确!\n");
break;
}
else if(i<3)
{
printf("错误,请重新回答:\n");
}
else
{
err++;
break;
}
}
num++;
if(num==10)break;
}
printf("\n得分:%d 正确率:%d%\n",100-err*10,100-err*10);
getch();
}
❽ 用C语言 给小学生出加法考试题
#include <stdlib.h>
#include <stdio.h>
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<10;k++){
i = rand()%10+1;
j = rand()%10+1;
printf("i=%d,j=%d\n",i,j);
m = AddTest(i,j);
sum+=m*10;
wsum-=m;
}
printf("The score is %d,and the wrong number is %d\n",sum,wsum);
return 0;
}
四则运算题可以产生随机数之后按其%4+1的结果来控制产生随机的四种运算,其他地方类似
❾ 用C语言写小学生四则运算测试练习
/*
* =====================================================================================
*
* Filename: small.c
*
* Description:
*
* Version: 1.0
* Created: 2020年07月02日 11时07分39秒
*
* Author: Deep Lee
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int getNum() {
srand(time(NULL));
return rand();
}
int main() {
int count = 10;
int score = 0;
int retry = 3;
for (; count > 0; count--) {
int num1 = getNum() % 100;
int num2 = 0;
if (getNum() % 2 == 0) { //+
num2 = getNum() % (100 - num1);
int result = num1 + num2;
int in = -1;
printf("%d + %d = \n", num1, num2);
for (retry = 3; retry > 0; retry--) {
scanf("%d", &in);
if (in == result) {
if (retry == 3) {
score += 10;
} else if (retry == 2) {
score += 7;
} else if (retry == 1) {
score += 5;
}
break;
} else {
if (retry > 1) {
printf("error: please re input\n");
} else {
printf("error: right result: %d\n", result);
}
}
}
} else { //-
num2 = getNum() % num1;
int result = num1 - num2;
int in = -1;
printf("%d - %d = \n", num1, num2);
for (retry = 3; retry > 0; retry--) {
scanf("%d", &in);
if (in == result) {
if (retry == 3) {
score += 10;
} else if (retry == 2) {
score += 7;
} else if (retry == 1) {
score += 5;
}
break;
} else {
if (retry > 1) {
printf("error: please re input \n");
} else {
printf("error: right result: %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;
}