0 Members and 2 Guests are viewing this topic.
/* rand example: guess the number */#include <iostream>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <time.h>using namespace std;int randomgen(int range, int bottom);int addition();int subtraction();int multiplication();int division();int score=0;int main(){ srand(time(NULL)); int randint, wrongs=0; for(int i; i<20; i++) { if(score<3) { randint=randomgen(6,0); if(randint==5) { wrongs+=addition(); } else if(randint==4) { wrongs+=subtraction(); } else if(randint==3) { wrongs+=multiplication(); } else if(randint==2) { wrongs+=division(); }/* else if(randint==1) { wrongs+=simplelinear(); } else { randint=randomgen(3,0); if(randint==0) { wrongs+=determinant(); } else if(randint==1) { wrongs+=scalarmultiplication(); } else { wrongs+=cts(); } }*/ } } system("PAUSE");}//Function Definitionsint randomgen(int range, int bottom){ int iSecret; iSecret = rand()%range+bottom; return iSecret;}int addition(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(600, 50); cout << "What is %d + %d equal ", numone, numtwo; cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score++; return 0; } else { return 1; }}int subtraction(){ int numone, numtwo, answer; numone=randomgen(200, 799); numtwo=randomgen(800, 1); cout << "What is %d - %d equal ", numone, numtwo; cin >> answer; cout << "\n"; if(answer==numone-numtwo) { score++; return 0; } else { return 1; }}int multiplication(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(750, 50); cout << "What is %d * %d equal ", numone, numtwo; cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score+=2; return 0; } else { return 1; }}int division(){ int numone, numtwo, answer; numtwo=randomgen(350, 50); numone=numtwo*randomgen(900, 100); cout << "What is %d / %d equal ", numone, numtwo; cin >> answer; cout << "\n"; if(answer==numone/numtwo) { score+=2; return 0; } else { return 1; }}
'MAP.exe': Loaded 'E:\MAP\MAP\Debug\MAP.exe', Symbols loaded.'MAP.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB fileThe program '[8712] MAP.exe: Native' has exited with code -1073741790 (0xc0000022).
#include <iostream>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <time.h>using namespace std;int randomgen(int range, int bottom);int addition();int subtraction();int multiplication();int division();int score=0, wrongs=0;int main(){ srand(time(NULL)); int randint; for(int i=0; i<20; i++) { if(score<3) { randint=randomgen(6,0); if(randint==5) { wrongs+=addition(); } else if(randint==4) { wrongs+=subtraction(); } else if(randint==3) { wrongs+=multiplication(); } else if(randint==2) { wrongs+=division(); }/* else if(randint==1) { wrongs+=simplelinear(); } else { randint=randomgen(3,0); if(randint==0) { wrongs+=determinant(); } else if(randint==1) { wrongs+=scalarmultiplication(); } else { wrongs+=cts(); } }*/ if(wrongs>=10) { break; } } } system("PAUSE");}//Function Definitionsint randomgen(int range, int bottom){ int iSecret; iSecret = rand()%range+bottom; return iSecret;}int addition(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(600, 50);// cout << "What is %d + %d equal ", numone, numtwo; uncomment when figure out how to make it work cout << "What is " << numone << "+" << numtwo << " equal "; cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score++; } else { wrongs++; }}int subtraction(){ int numone, numtwo, answer; numone=randomgen(200, 799); numtwo=randomgen(800, 1); cout << "What is " << numone << "-" << numtwo << " equal "; cin >> answer; cout << "\n"; if(answer==numone-numtwo) { score++; } else { wrongs++; }}int multiplication(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(750, 50); cout << "What is " << numone << "*" << numtwo << " equal "; cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score+=2; } else { wrongs++; }}int division(){ int numone, numtwo, answer; numtwo=randomgen(350, 50); numone=numtwo*randomgen(900, 100); cout << "What is " << numone << "/" << numtwo << " equal "; cin >> answer; cout << "\n"; if(answer==numone/numtwo) { score+=2; } else { wrongs++; }}
#include <iostream>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <time.h>using namespace std;int randomgen(int range, int bottom);int addition();int subtraction();int multiplication();int division();int simplelinear();int score=0, wrongs=0;int main(){ srand(time(NULL)); int randint; for(int i=0; i<20; i++) { cout << score; cout << "\n"; cout << i; cout << "\n"; if(score<3) { randint=randomgen(6,0); if(randint==5) { wrongs+=addition(); } else if(randint==4) { wrongs+=subtraction(); } else if(randint==3) { wrongs+=multiplication(); } else if(randint==2) { wrongs+=division(); } else if(randint==1) { wrongs+=simplelinear(); }/* else { randint=randomgen(3,0); if(randint==0) { wrongs+=determinant(); } else if(randint==1) { wrongs+=scalarmultiplication(); } else { wrongs+=cts(); } }*/ if(wrongs>=10) { break; } } } system("PAUSE");}//Function Definitionsint randomgen(int range, int bottom){ int iSecret; iSecret = rand()%range+bottom; return iSecret;}int addition(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(600, 50); printf("what is %d+%d ", numone, numtwo); cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score++; return 0; } else { wrongs++; return 0; }}int subtraction(){ int numone, numtwo, answer; numone=randomgen(200, 799); numtwo=randomgen(800, 1); printf("what is %d-%d ", numone, numtwo); cin >> answer; cout << "\n"; if(answer==numone-numtwo) { score++; return 0; } else { wrongs++; return 0; }}int multiplication(){ int numone, numtwo, answer; numone=randomgen(900, 100); numtwo=randomgen(750, 50); printf("what is %d*%d ", numone, numtwo); cin >> answer; cout << "\n"; if(answer==numone+numtwo) { score+=2; return 0; } else { wrongs++; return 0; }}int division(){ int numone, numtwo, answer; numtwo=randomgen(350, 50); numone=numtwo*randomgen(900, 100); printf("what is %d/%d ", numone, numtwo); cin >> answer; cout << "\n"; if(answer==numone/numtwo) { score+=2; return 0; } else { wrongs++; return 0; }}int simplelinear(){ int numone, slope, intercept, answer, correct; slope=randomgen(50, 1); intercept=randomgen(300, 500); correct=randomgen(200, 1); numone=slope*correct-intercept; printf("what is x if %dx+%d=%d ", slope, intercept, numone); cin >> answer; cout << "\n"; if(answer==correct) { score+=2; return 0; } else { wrongs++; return 0; }}