这个怎么编啊?

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:31:12
小学生算术练习题,随机产生10题2位数加法练习题,由学生解答并统计答对题目数?帮帮忙啊
谢谢!

// c++代码
// 这个程序不好的地方是每次都是相同的10个算式,如果每次产生不同的10
// 个算式,联系emial: zhbandnegro@163.com
#include <iostream>
#include <cstdlib>
using namespace std;
int getRand();
int main()
{
int x, y;
int answer;
const int COUNT = 2; // 学生要做的题目数
int right = 0; // 答对的次数
int wrong = 0;
double rate; // 正确率 = 答对的次数/回答的次数
for (int i = 0; i < COUNT; i++)
{
x = getRand();
y = getRand();
while (true)
{
cout << "---->No." << i + 1 << ": " << x << " + " << y << " = ";
cin >> answer;
if (answer == x + y)
{
right++;
break;
}
else // 如果不想要再回答此题,只要把else{...}