Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #include <fstream>
- using namespace std;
- int sum(int a, int b)
- {
- int c;
- c = a + b;
- return c;
- }
- bool isNumber(char Symbol)
- {
- if (Symbol >= '0' && Symbol <= '9')
- return true;
- return false;
- }
- void registration(string name1, string pass1, bool IsRegistered)
- {
- cout << "Your username: ";
- cin >> name1;
- cout << "Your password: ";
- cin >> pass1;
- ofstream fout;
- fout.open(name1);
- fout << "Username = " << name1 << endl;
- fout << "Password = " << pass1 << endl;
- cout << "Great! You've signed up! Now come check your math calculation skills!" << endl;
- cout << "If you wish to leave the game, type in F" << endl;
- IsRegistered = true;
- }
- void check(int a, int b, int c, int v, int solved, string name1)
- {
- c = sum(a, b);
- if (c == v)
- {
- cout << "Your answer is correct";
- cout << endl;
- solved++;
- }
- else
- {
- cout << "Your answer is incorrect";
- cout << endl;
- }
- }
- void output(int a, int b, int c, int v, int solved, string name1)
- {
- srand((unsigned)time(NULL));
- a = 1 + rand() % 1000;
- b = 1 + rand() % 1000;
- heh:
- cout << "Solve it - " << a << " + " << b << endl;
- cout << "Your answer: ";
- cin >> v;
- if (v > 9999)
- {
- cout << "Sorry, your number cannot be so big." << endl;
- goto heh;
- }
- else
- {
- check(a, b, c, v, solved,name1);
- output(a, b, c, v, solved, name1);
- }
- }
- int main()
- {
- //bool correct = false;
- srand((unsigned)time(NULL));
- int v = 0;
- int a = 0;
- int b = 0;
- int c = 0;
- int solved = 0;
- string name1, pass1;
- bool IsRegistered = false;
- registration(name1, pass1, IsRegistered);
- output(a, b, c, v, solved, name1);
- system("pause");
- }
Add Comment
Please, Sign In to add comment