mardi 19 janvier 2016

Remove a choice from a picked statement

Basically what I'm trying to do, is to let the user enter a number between 1-3, and when that number is entered, an if-statement is going to execute..

However, I want this loop to go through all the cookies (which it does) til everyone is chosen and the same number cant be picked. Would appreciate it if you looked through my code and could explain how I should be doing?

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main()
{
    string luck;
    int cookies = 3;
    int choice;
    int *taken;

    for (int i = 0; i < 3; i++) {

        cout << "What cookie do you want?";
        cin >> choice;

        if (choice == 1) {
            cout << "Tomorrow is a day";
        }
        if (choice == 2) {
            cout << "Tomorrow can be cool";
        }
        if (choice == 3) {
            cout << "Summer is coming";
        }
        choice--; //not working though, something wrong im doing i guess.
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire