Random Sentence Generator

So, I've successfully made a program that prompts the user to enter 10 nouns and 10 verbs and randomly selects two nouns and one verb to display a sentence. But, I'm struggling to check the user input for duplicate entries, such as if they enter the noun "bird" twice. Is there a way to check the user input for duplicate word entries? I've tried storing the input as a string and a string array and still can't figure out how to perform this check. Any help would be appreciated!
posting the code might help.
also you could check if say stringarray[1] is equal to any other.
then check for 2
but that is very uneficient
sadly i don't know any other ways
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class Word
{
    
public:
    
    Word() { word = '\0'; }
    void setWord (string);
    string getWord ();
    
private:
    
    string word;
    
};

void Word::setWord(string word1)
{
    word = word1;
}


string Word::getWord()
{
    return word;
}



int main()
{
    Word Noun[10];
    Word Verb[10];
    int num_sent;
    string nouns, verbs;
    
    cout << "\nThis program is a Nonsense Sentence Generator!" << endl << endl;
    cout << "Enter 10 unique, singular nouns, separated by a space, hitting <Enter> when done: " << endl;
    
    for (int i = 0; i < 10; i++)
    {
        cin >> nouns;
        Noun[i].setWord(nouns);
    }
    
    cout << "\nNow, enter 10 unique, third-person singular present verbs, separated by a space, hitting press <Enter> when done: " << endl;
    
    for (int k = 0; k < 10; k++)
    {
        cin >> verbs;
        Verb[k].setWord(verbs);
    }
    
    cout << "\nHow many sentences do you wish to see? ";
    cin >> num_sent;
    cout << endl << endl;
    
    srand(unsigned(time(0)));
    for (int m = 0; m < num_sent; m++)
    {
        int firstWord;
		int secondWord;
		int verb = rand() % 10;
		firstWord = secondWord = rand() % 10;
		
		while(secondWord == firstWord)
        {
			secondWord = rand() % 10;
		}
        
        cout << "The " << Noun[firstWord].getWord() << " " << Verb[verb].getWord() << " the " << Noun[secondWord].getWord() << "." << endl;
	}
    
	cout << endl << endl << endl;
    return 0;
}



just some beginners input on the idea here, isnt it possible to perform a check within the For loop , right after the user inputs "Break" , you can check if there is already an input like that in your string arrays before actually storing it to the next one, sorry if im intruding where i shouldnt, thought maybe it'd enlighten you a little on your case :)
Topic archived. No new replies allowed.