題目:小學生計算機輔助教學系統(tǒng)
編寫一個程序,幫助小學生學習乘法。然后判斷學生輸入的答案對錯與否,按下列任務要求以循序漸進的方式分別編寫對應的程序并調(diào)試。文章來源:http://www.zghlxwxcb.cn/news/detail-684744.html
- 任務1 程序首先隨機產(chǎn)生兩個1—10之間的正整數(shù),在屏幕上打印出問題。例如:6*7=?然后輸入答案,如果輸入答案正確,則顯示“Right!”,然后問下一個問題;否則顯示“Wrong!Please try again.”,然后提示學生重做,直到答對為止。(略)
- 任務2 在任務1的基礎之上,當學生回答錯誤時,最多給三次重做,三次仍未做對,則顯示“Wrong!You have tried three times!Test over!”,程序結束。
- 任務3 在任務1的基礎上,連續(xù)做10道乘法運算題,不給機會重做,若學生回答正確,則顯示“Right!”,否則顯示“Wrong!”。10道題全部做完后,按每題10分統(tǒng)計并輸出總分,并輸出學生的回答正確率。
- 任務4 在任務2的基礎上,為了提高程序的可讀性,完善人機對話界面,從而達到來吸引學生的注意力,故要為學生輸入的每一個正確或錯誤的答案輸出不同的評價,正確的答案評價分為四個等級:“Very good!”、“Excellent!”、“Nice work!”、“Keep up the good work!”,錯誤的答案評價分為三個等級:“No.Please try again.”、“Wrong.Try once more.” ,“Don’t give up!”。
- 任務3 在任務1的基礎上,連續(xù)做10道乘法運算題,不給機會重做,若學生回答正確,則顯示“Right!”,否則顯示“Wrong!”。10道題全部做完后,按每題10分統(tǒng)計并輸出總分,并輸出學生的回答正確率。
- 任務2 在任務1的基礎之上,當學生回答錯誤時,最多給三次重做,三次仍未做對,則顯示“Wrong!You have tried three times!Test over!”,程序結束。
// 任務2
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char const *argv[]) {
int computerProduct, myProduct, num1, num2, redoNumber;
srand(time(NULL));
for (;;) {
redoNumber = 0;
// 產(chǎn)生兩個 1~10 之間的隨機數(shù)
num1 = rand() % 10 + 1;
num2 = rand() % 10 + 1;
// 電腦計算結果
computerProduct = num1 * num2;
do {
printf("%d * %d = ? ", num1, num2);
// 我的計算結果
scanf("%d", &myProduct);
if (myProduct == computerProduct) {
printf("Right!\n");
break;
}
// 若同一題連續(xù)錯誤三次則直接結束測試
if (redoNumber == 3) {
printf("Wrong!You have tried three times!Test over!");
break;
} else printf("Wrong!Please try again.\n");
redoNumber++;
} while (myProduct != computerProduct);
if (redoNumber == 3) break;
}
return 0;
}
// 任務3
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char const *argv[]) {
int computerProduct, myProduct, num1, num2, winNumber = 0, questionsNumber, i;
srand(time(NULL));
for (questionsNumber = 1; questionsNumber <= 10; questionsNumber++) {
// 產(chǎn)生兩個 1~10 之間的隨機數(shù)
num1 = rand() % 10 + 1;
num2 = rand() % 10 + 1;
// 電腦計算結果
computerProduct = num1 * num2;
printf("%d * %d = ? ", num1, num2);
scanf("%d", &myProduct);
if (myProduct == computerProduct) {
printf("Right!\n");
winNumber += 10;
} else printf("Wrong!\n");
}
// 統(tǒng)計分數(shù)
printf("學生得分:%d\n", winNumber);
// 統(tǒng)計得分率(questionsNumber++最后累計到 11)
printf("學生得分率:%d%%", winNumber * 10 / --questionsNumber);
return 0;
}
// 任務4
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char const *argv[]) {
int computerProduct, myProduct, num1, num2, redoNumber, winNumber = 0;
srand(time(NULL));
for (;;) {
// 只要出現(xiàn)正確則把累計的錯誤次數(shù)清零
redoNumber = 0;
// 產(chǎn)生兩個 1~10 之間的隨機數(shù)
num1 = rand() % 10 + 1;
num2 = rand() % 10 + 1;
// 電腦計算結果
computerProduct = num1 * num2;
do {
// 只要出現(xiàn)錯誤則把累計的正確次數(shù)清零
if (redoNumber != 0)
winNumber = 0;
printf("%d * %d = ? ", num1, num2);
scanf("%d", &myProduct);
if (myProduct == computerProduct) {
winNumber++;
// 輸出對應正確次數(shù)的語句
switch (winNumber) {
case (1):
printf("Keep up the good work!");
break;
case (2):
printf("Nice work!");
break;
case (3):
printf("Excellent!");
break;
default:
printf("Very good!");
break;
}
printf("\n");
break;
} else redoNumber++;
switch (redoNumber) {
case (1):
printf("No.Please try again.");
break;
case (2):
printf("Wrong.Try once more.");
break;
case (3):
printf("Don't give up!");
break;
}
if (redoNumber == 3) break;
printf("\n");
} while (1);
if (redoNumber == 3) break;
}
return 0;
}
結果展示
文章來源地址http://www.zghlxwxcb.cn/news/detail-684744.html
到了這里,關于C語言程序設計——小學生計算機輔助教學系統(tǒng)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!