1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
[tt]#include<cstdio>
#include<iostream>
#include <cmath>
using namespace std;
const int QUESTIONS = 5;
int difficulty_level;
//function to generate a question and return two numbers
//call by reference
void two_numbers(int low,int high,int& num1,int& num2); //one question
bool ask_question(int low,int high,int& no_correct,int& no_uncorrect); //set of questions
//what else?
//function to generate a random number
int random (int low, int high);
//function to get low and high provided difficulty level
void get_bounds(int deff,int& low, int& high);
int main()
{
//enter difficulty level;
cout<<"Enter difficulty level";
cin>>difficulty_level;
cout<<endl;
//cin>>difficulty level;
//ask a question 5 times???//use a for loop?
system("pause");
return 0;
}
void two_numbers(int low,int high,int& num1,int& num2)
{
num1=random(low,high);
num2=random(low,high);
}
bool ask_question(int low,int high,int& no_correct,int& no_uncorrect)
{
int num1,num2;
bool yes;
//calculate two numbers
two_numbers(low,high,num1,num2);
cout<<num1<<"*"<<num2<<"?:";
cin>>enter;
//check if the number enter by the user is right or wrong
if(enter==right)
{ cout<<"correct!"<<endl;
no_correct++;
yes=true;
}
else
{
no_incorrect++;
}
}
//function to generate a random number between low and high
int random(int low,int high)
{
return rand()&(high-low)+low;
}
void get_bounds (int diff,int& low,int& high);
{
low=static_cast<int>(pow(10.0,(diff=1)));
high=static_cast<int>(pow(10.0,(diff=1)));
|