新人求助//为什么有时候运行不到十次就不显示了?
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(0));
int i,j,k;
j=k=0;
for(i=0;i<10;i++)
{
int a=rand()%10;
int b=rand()%10;
int op=(rand()%4)+1 ;
int answer;
switch(op)
{
case 1:
op='+';
answer = a+b;
break;
case 2:
do
{int a=rand()%10;
int b=rand()%10;}
while(a<b);
op='-';
answer=a-b;
break ;
case 3:
op='*';
answer=a*b;
break;
case 4:
do
{int a=rand()%10;
int b=rand()%10;}
while(b==0 || a%b!=0);
op='/';
answer=a/b;
break;
}
int d;
cout<<a<<char(op)<<b<<"=";
cin>>d;
if(d==answer)
{
j++;
cout<<"Right!" <<endl;
}
else
{
k++;cout<<"Not correct!"<<endl;}
}
cout<<"you got "<<j*10<<" scores, you made "<<k<<" mistakes."; }