C语言入门 -- 计算机辅助教学【练习加减乘除】(2021/1/21)

本文介绍了使用C语言创建计算机辅助教学程序,帮助小学生学习加减乘除。程序通过生成随机数学问题,检查学生答案并提供反馈,同时考虑了不同难度级别和问题类型的选择,以增强学生的学习体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

计算机辅助教学

帮助小学生学习加减乘除

随着计算机成本的下降,对每个学生来说,不管经济状况如何,拥有一台计算机并在学校里使用变得可行。这为改善全世界所有学生的教育体验创造了令人兴奋的可能性,如下面五个练习所示。
(1) 计算机辅助教学:简易版本
在教育中使用计算机被称为计算机辅助教学(CAI)。
写一个帮助小学生学习乘法的程序。使用rand函数生成两个正的一位数整数。然后程序应该提示用户一个问题,比如
How much is 6 times 7?
然后学生输入答案。接下来,程序检查学生的答案。如果正确,则显示消息“Very good!”再问一个乘法题。如果答案是错误的,显示“No. Please try again.”的信息,并让学生重复回答同一个问题,直到学生最终答对为止。应使用单独的函数生成每个新问题。
每次应用程序开始执行时,用户都应该正确地回答一次问题。

/*
  Name:programme5(1).c
  Author:祁麟
  Copyright:BJTU | school of software
  Date:2020/10/31
  Description: Computer-Assisted Instruction(1)
*/

#include <stdio.h>
#include <time.h>

int question();
void loop();

//生成随机数并计算乘积提出问题 
int question(){
   
	int num1,num2,result;
	
	time_t seed=0;
	time_t now=0;
	
	seed = time(NULL);
	now = clock();
			
	srand((unsigned int)seed);
	num1=rand()%10;
	num2=rand()%10;
	result=num1*num2;
	printf("How much is %d times %d ? \n",num1,num2);
    
    return result;
} 

//循环提出问题 
void loop(){
   
	
	int Result,answer,i=1;
	
	while(i<=2){
   

	    Result=question(); 
		printf("please enter your answer:");
	    scanf("%d",&answer);
	    if (answer==Result){
   
		    printf("Very good!\n\n");
		    i++;
		    continue;
	    }
	    else {
   
		    printf("No. Please try again.\n");
		    scanf("%d",&answer);
		    while (answer!=Result){
   
		    	printf("No. Please try again.\n");
		    	scanf("%d",&answer);
			}
			if (answer==Result){
   
				printf("Very good!\n\n");
				i++;
			}
	    }
    }
}

//主函数
int main(){
   
	loop();
	return 0;
} 

运行截图:
截图(1)

(2) 计算机辅助教学:减轻学生疲劳
CAI环境中的一个问题是学生的疲劳。这可以通过改变计算机的反应来吸引学生的注意力来减少。修改(1)的程序,以便为每个答案显示不同的注释,如下所示:
正确答案:
Very good!
Excellent!
Nice work!
Keep up the good work!
对不正确答案的可能回答:
No. Please try again.
Wrong. Try once more.
Don’t give up!
No. Keep trying.
使用随机数生成从1到4选择一个数字,用于从四个适当的答案中选择一个对每个正确或不正确的答案。使用switch语句发出响应。

/*
  Name:programme5(2).c
  Author:祁麟
  Date:2020/11/6
  Description: Computer-Assisted Instruction(2)
*/

#include <stdio.h>
#include <time.h>

void loop();
int question();
char *trueResponse();
char *falseResponse();

//生成随机数并计算乘积 
int question(){
   
	int num1,num2,result;
	
	time_t seed=0;
	time_t now=0;
	
	seed = time(NULL);
	now = clock();			
	srand((unsigned int)seed);
	num1=rand()%10;
	num2=rand()%10;
	result=num1*num2;
	printf("How much is %d times %d ? \n",num1,num2);
    return result;
} 

//对于正确答案生成不同应答
char *trueResponse() {
   
	int SWITCH;
	SWITCH=rand()%4;
	switch (SWITCH){
   
		case 1:return("Very good!\n");
		case 2:return("Excellent!\n");
		case 3:return("Nice work!\n");
		default:return("Keep up the good work!\n");
    }
}

//对于错误答案生成不同应答
char *falseResponse() {
   
	int SWITCH;
	SWITCH=rand()%4;
	switch (SWITCH){
   
		case 1:return("No. Please try again.");
		case 2:return("Wrong. Try once more.");
		case 3:return("Don't give up!");
		default:return("No. Keep trying.");
	} 
	
}

//循环提出问题 
void loop(){
   
	
	int Result,answer,i=1;
	
	while(i<=2){
   

	    Result=question(); 
		printf("please enter your answer:");
	    scanf("%d",&answer);
	    if (answer==Result){
   
		    printf("%s\n",trueResponse());
		    i++;
		    continue;
	    }
	    else {
   
		    printf("%s\n",falseResponse());
		    scanf("%d",&answer);
		    while (answer!=Result){
   
		    	printf("%s\n",falseResponse());
		    	scanf("%d",&answer);
			}
			if (answer==Result){
   
				printf("%s\n",trueResponse())
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

RowdyKid

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值