小学生加法出题器

#include <iostream>
#include <ctime>
using namespace std;
double jiafa(double a,double b);
int main()
{

srand (time(0));
double a,b,n,i,score=0;
cout<<"答对有十分,答错没有分。满分100分。亲~加油!"<<endl;
for (i = 0; i < 10; i++)
{
a = rand() % 999 + 1;
b = rand() % 999 + 1;
cout << a << '+' << b << "= ? ";
n=jiafa(a,b);
if (n == 1)
{
cout << "Right!" << endl;
score=score+10;
}
else
{
cout << "Not correct!" << endl;
}
}
cout << "你的分数是: " << score << " !" << endl;
return 0;
}
double jiafa(double a,double b)
{ double c;
cin>>c;
if(c==a+b)
return 1;
else
return 0;
}

posted @ 2012-12-06 15:57  呆到久时自然萌  阅读(165)  评论(1编辑  收藏  举报