Laiq Ahmed 42 Junior Poster

Hi,
your question is bit unclear... what are you storing in the multimap logically. What I've understood is that you want to get the multiple values against the same key

multimap<int, string>  mm;
	mm.insert(std::make_pair(1, "a"));
	mm.insert(std::make_pair(1, "c"));
	mm.insert(std::make_pair(2, "d"));
	mm.insert(std::make_pair(2, "e"));

	typedef pair<multimap<int, string>::iterator, multimap<int, string>::iterator>  Pair_Range;
	Pair_Range  pRange = mm.equal_range(1);
	
	for (multimap<int, string>::iterator it = pRange.first; it != pRange.second; ++it) {
		cout << it->second<<endl;
	}

Hope this helps

iamthwee commented: no -4
Laiq Ahmed 42 Junior Poster

I want to generate the following pattern using for() loop only.... how can i do this i've tried but unfortunately failed to solve ....

when user inputs 3
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1

when user inputs 4;

1 1 1 1 1 1 1
1 2 2 2 2 2 1
1 2 3 3 3 2 1
1 2 3 4 3 2 1
1 2 3 3 3 2 1
1 1 1 1 1 1 1

I just want to know the algorithm or just a hint?