Norway


#include <bits/stdc++.h>

using namespace std;

 

// Function to all of that can be

// by from each of the given

void printAllCombinations(auto list, int n, string res, int listNum)

{

    // if we have traversed each list

    if (listNum == n)

    {

        // print phrase after removing trailing space

        cout << res.substr(1) << endl;

        return;

    }

 

    // get size of current list

    int m = list[listNum].size();

    

    // do for each word in current list

    for (int i = 0; i < m; i++)

    {

        // append current word to output

        string out = res + ” R; + list[listNum].at(i);

 

        // recurse for next list

        printAllCombinations(list, n, out, listNum + 1);

    }

}

 

// main function

int main()

{

    vector<string> list[] =

    {

        { “John”, “Emma” },

        { “Plays”, “Hates”, “Watches” },

        { “Cricket”, “Soccer”, “Chess” }

    };

    

    // size of the list

    int n = sizeof(list)/sizeof(list[0]);

 

    printAllCombinations(list, n, “”, 0);

 

    return 0;

}



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here