#include<iostream>
#include<string>
#include <cstdlib> //rand
#include<ctime>
#include <algorithm> //shuffling
#include <vector>

using namespace std;

int main()
{
    int option,i=0, num_part;
    vector<string> names;

    cout << "Welcome to Number-guessing Game !\n\n";

    do
    {

        cout << "Menu" << endl;
        cout << "-----" << endl;
        cout << "1)To register number of participants and name " << endl;
        cout << "2)To start the game" << endl;
        cout << "3)To show ranking" << endl;
        cout << "4)To quit\n\n";

        cout << "Option:";

        cin >> option;
        cout << "\n\n";

        if (option == 1)
        {
            cout << "Please enter the number of participants <1-5>:";
            cin >> num_part;
            cout << "\n";


            names.resize(num_part);
            for (vector<string>::size_type i = 0; i < num_part; i++)
            {
                cout << "Enter your name " << i + 1 << ":" ;
                getline(cin, names[i]);
                cin >> names[i];
            }

            cout << "\n\n";
        }

        else if (option == 2)
        {
            system("CLS");
            srand((unsigned)time(NULL));

            while (true)
            {

                int a = rand() % 9 + 1;
                int b = rand() % 9;
                int c = rand() % 9;
                int d = rand() % 9;
                int array[4] = { a, b, c, d };


                if (a != b && a != c && a != d && b != c && b != d && c != d)
                {
                    cout << "The random numbers generated is:";
                    for (int x = 0; x < 4; x++)
                        cout << array[x];
                    cout << endl;

                    break;

                }

            }

            system("PAUSE");
            system("CLS");

            for (vector<string>::size_type i = 0; i < num_part; i++)
            {

                cout << names[i] << " ,its your turn. Press any key to start the game." << endl;
            }
        }

    } while (option < 5);


        return 0;
}

If you don't specify what the problem is, how should we know?
We have no time to wade through your code to find the problem, so please tell us what the problem is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.