16,472
社区成员
发帖
与我相关
我的任务
分享
// times.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,t;
int time=0;
char quit;
ofstream fout;
fout.open("file.dat");
for (int i=0;i<=100;i++)
{
a=rand()%100;
b=rand()%100;
if (a<b)
{
t=a;
a=b;
b=t;
}
cout<<"how much is "<<a<<" times "<< b <<"=?"<<endl;
cin>>c;
if(c==a*b)
{
cout<<"very good"<<endl;
continue;
}
else
{
fout<<a<<"x"<<b<<"="<<c<<endl;
}
time++;
if (time==45)
{
cout<<"You hava finish 45 time.Continue?(Y/N)"<<endl;
cin>>quit;
if (quit=='N')
{
break;
}
else
{
time=0;
}
}
}
fout.close();
return 0;
}