Hello! So I have this homework that i have no idea how to continue.
this is an exemple of input,but i have to do it for a general one:
7
pencils car ball candy tshirt bike video_game
Mike Andrew Inna

and the output must be like this:

Mike: pencils candy video_game
Andrew: car tshirt
Ioana: ball bike

we have to use a queue and this is what I wrote,but I don't know what should i do next. Can Somebody help me,please?

#include <iostream>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
using namespace std;

int main() {
    int n,j=0;
    queue<string> cadouri;
    vector<string> names;

    string ob,nume1;

    cin>>n;
    for(int i=0 ;i<n;i++) { //push the 7 things in the queue
        cin >> ob;
        cadouri.push(ob);
    }

    while(cin>>nume1)//push the names in the vector
    {
        names.push_back(nume1);
        j++;

    }

    ???

    return 0;
}

Just me thinking it through the ??? section in psuedocode:

while there are objects in the queue
{
  for loop interating the names vector from first to last
    {
     if there are objects in the queue, pop one into the named vector
    }
}
commented: Thank you so much, i think it would be more difficult ,but I was thinking of a harder solution :) +0
Be a part of the DaniWeb community

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