mercredi 14 avril 2021

How do I make C++ choose a random phrase from several?

I'm a complete beginner when it comes to programming and C++ and I'm trying to make a console app where you input a genre, and it chooses one of six movies in the genre.

I'm just trying to find out how to make it output one movie of around 6-10.

#include <iostream>
#include <string>
#include <random>
#include <string.h>
using namespace std;

int main()
{



    string cri, dra, rom, war, west, hor, act, scifi, thril, com, movie;
    cri = "crime";
    dra = "drama";
    rom = "romance";
    war = "war";
    west = "western";
    hor = "horror";
    act = "action";
    scifi = "scifi";
    thril = "thriller";
    com = "comedy";


    cout << "Welcome to Random Movie Shuffler. Select a genre, and you'll receive a random movie of that genre!\n" << endl;
    cin >> movie;

    if (movie == cri)
    {

        string crim;
        crim = ("movie 1", "movie 2", "movie 3", "movie 4", "movie 5", "movie 6");
    
        cout << "Check out " << crim << endl;

    }



Aucun commentaire:

Enregistrer un commentaire