计算机辅助教学
帮助小学生学习加减乘除
随着计算机成本的下降,对每个学生来说,不管经济状况如何,拥有一台计算机并在学校里使用变得可行。这为改善全世界所有学生的教育体验创造了令人兴奋的可能性,如下面五个练习所示。
(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;
}
运行截图:
(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())