Sorting vectors

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2009
Posts: 110
Reputation: s_sridhar has a little shameless behaviour in the past 
Solved Threads: 11
s_sridhar's Avatar
s_sridhar s_sridhar is offline Offline
Junior Poster

Re: Sorting vectors

 
0
  #11
May 13th, 2009
don't make this simple thing complex, declare a 2 dimensional array of large size. and assign a[i][0]=i; if the array element exists already a[i][1]=i; Count the frequencies and store it in a seperate array 10 11 12 13 14
10 11 13 14
10 11
11 as shown. now sort the frequencies and display the contents of the corresponding buckets
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 27
Reputation: newcook88 is an unknown quantity at this point 
Solved Threads: 0
newcook88 newcook88 is offline Offline
Light Poster

Re: Sorting vectors

 
0
  #12
May 13th, 2009
how do i get it to print im an not sure how to becasue it is my first time with maps when i try the below method it is not working

for(unsigned int i=1;i<output.size ();i++)
{
cout<<output[i]<<endl;
}
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 27
Reputation: newcook88 is an unknown quantity at this point 
Solved Threads: 0
newcook88 newcook88 is offline Offline
Light Poster

Re: Sorting vectors

 
0
  #13
May 13th, 2009
i managed to print it but the sorting is done in an accessedint order i need to sort in decending order

sort(output.begin(),output.end(),sort_pred);
for(unsigned int i=0;i<output.size() ;i++)
{
cout<<output[i].second <<endl;
}
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 27
Reputation: newcook88 is an unknown quantity at this point 
Solved Threads: 0
newcook88 newcook88 is offline Offline
Light Poster

Re: Sorting vectors

 
0
  #14
May 13th, 2009
problem solved got da rbegin and rend
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC