All pastes #556539 Raw Edit

Door program

public cpp v1 · immutable
·published 2007-06-10 17:01 UTC
rendered paste body
#include <cstdlib>#include <iostream>#include <time.h>using namespace std;int main(int argc, char *argv[]){        //initalize program    int runs;    bool changedoor;    int wins, door_correct, door_select, door_remove;    cout.precision(2);        cout << "FUCKEN AWESOME DOOR APPLICATION\n";    cout << "   _____    _____   _____\n";    cout << "   |   |    |   |   |   |\n";    cout << "   |  _|    |  _|   |  _|\n";    cout << "   |   |    |   |   |   |\n";    cout << "   |___|    |___|   |___|\n";    cout << "\n by Tomas \"Toumaz\" Olander\n\n";    cout << "You have three doors in front of you - one of them\ncontaining a grand prize and the other two are empty.\n";    cout << "After picking an initial door one of the fake doors\nare opened, revealing its contents.\n\n";    cout << "You are asked if you wish to change door or not.\nWhat do you do?";    cout << "\n\n";        //set up the number of programme runs        start:        cout << "Enter the number of times you wish to pick a door: ";    cin >> runs;    cout << "\n";        //ask for Y/N        cout << "Should the person change his/her selection after the revelation?\n";    cout << "0: No  1: Yes  Choice? ";    cin >> changedoor;    cout << "\nStarting...  ";        //set up some basic things    wins=0;        //set a random seed    srand ( time(NULL) );        //start the main loop    for (int i = 1; i <= runs; i++) {        door_correct=rand() % 3;        door_select=rand() % 3;                //we totally refuse to change door        if (changedoor == 0) {           if (door_select == door_correct) wins++;           }        //okay, we want to change door        else if (changedoor == 1) {           if (door_select != door_correct) wins++;              }        }           //Print out the results    cout << "finished!\n";    cout << "\n--------------------------------------------------\n";    cout << "Number of wins: " << wins << "/" << runs << "\n";    cout << "Win percentage: " << (wins*100.0/runs) << "%";    cout << "\n--------------------------------------------------\n\n";        goto start;        return EXIT_SUCCESS;}