Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <string> // I added the string lib so you can now use stirngs with std::string
- using std::cout;
- using std::cin;
- using std::endl;
- using std::system;
- /*
- I have declared a function here so that we can use it in a function call in main(), if
- we dont declare it here the function call wont know it exists because the function is below it.
- The other option is to move the entire function above main(), then the function call within
- main() will know it exists as it only looks above, not below.
- */
- // RULE: C++ Code can only look up, it can't look down!
- bool DoTheDance(int Runs);
- int main()
- {
- SetConsoleTitle( TEXT("NigraCalQ"));
- /*
- Here I want to keep replaying the function until the function tells me not to repeat any
- more. So what I've done is to create a bool (true/false) variable and assign the result
- of the function to it. If the function returns false the 'while' loop will stop. 'While'
- loops can only continue if it's argument is true, and they will continue to repeat until
- it's argument is false.
- I've also created a new int variable that will count how many times the function is run.
- In the 'while' loop after the function call I have called the variable and put a '++' after
- it. This is a simple way to say to the variable 'increase by 1!'.
- The last change you will notice is the 'if' statement in the loop. All this does is check if
- this is the first time the loop has been run, if it has then it will just put a new line in
- the console to spread things out a bit and make it a bit easier to read.
- */
- bool Dancing = true;
- int Runs = 0;
- while (Dancing)
- {
- if (Runs > 0) cout << "\n";
- Dancing = DoTheDance(Runs);
- Runs++;
- }
- system ("pause>nul"); // Google told me about this one.
- return 0;
- }
- /*
- Here is the implementation of the function that we have declared above.
- */
- bool DoTheDance(int Runs)
- {
- int Nig1;
- int Nig2;
- int DiffDeter;
- int DifResult;
- int BigNig;
- int LilNig;
- cout << "We have run this process " << Runs << " times before!\n";
- cout << "Enter the age of 2 them their niggras: ";
- cin >> Nig1 >> Nig2;
- if (Nig1);
- {
- if ( Nig1 != Nig2);
- cout << "You dun got 2 different aged niggras! Sheeeeeeeit..." << endl;
- DifResult = (Nig1 - Nig2);
- if (DifResult < 0)
- DiffDeter = (DifResult * -1);
- else
- DiffDeter = (DifResult * 1);
- cout << "Nogras be ";
- cout << DiffDeter;
- cout << " yeeaz apart." << endl;
- }
- else
- {
- if ( Nig1 > Nig2)
- BigNig = (Nig1 - Nig2);
- else
- BigNig = (Nig2 - Nig1);
- cout << "That first there niggra is ";
- cout << BigNig;
- if (Nig1 > Nig2)
- cout << " years older";
- else
- cout << " years youger";
- cout << " than that second niggra." << endl;
- }
- /*
- Now to see if the user wants to continue. If the user does want to continue then return
- the result of 'true', if not then return the result of false. Simples!
- */
- std::string ContinueTheDance;
- cout << "Do you still wanna dance? (y/n): ";
- cin >> ContinueTheDance;
- if (ContinueTheDance == "y")
- return true;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement