Click here to Skip to main content
15,905,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questioncompare character array with file in C Pin
robin70020-Nov-11 17:15
robin70020-Nov-11 17:15 
AnswerRe: compare character array with file in C Pin
«_Superman_»20-Nov-11 17:28
professional«_Superman_»20-Nov-11 17:28 
QuestionRe: compare character array with file in C Pin
David Crow20-Nov-11 17:29
David Crow20-Nov-11 17:29 
AnswerRe: compare character array with file in C Pin
robin70020-Nov-11 18:29
robin70020-Nov-11 18:29 
QuestionHow to find the most frequent value of string array, and how many Pin
sadas232341s20-Nov-11 2:58
sadas232341s20-Nov-11 2:58 
AnswerRe: How to find the most frequent value of string array, and how many Pin
Chris Losinger20-Nov-11 4:04
professionalChris Losinger20-Nov-11 4:04 
GeneralRe: How to find the most frequent value of string array, and how many Pin
sadas232341s20-Nov-11 6:26
sadas232341s20-Nov-11 6:26 
GeneralRe: How to find the most frequent value of string array, and how many Pin
Chris Losinger20-Nov-11 6:35
professionalChris Losinger20-Nov-11 6:35 
or, just use:
C++
std::sort(v_str.begin(), v_str.end())


so if you have a sorted list of strings:

aaa, aaa, bb, cc, ccc, dd, dd, dd, dd, e, f, g

iterate through the list, check to see when the current item is equal to the last item. if it's the same, keep track of how many times it repeats. if it's different, see if the number of repetitions was greater than the max number of reps you've seen so far.

cur = vec[0]
maxrep = 1
maxstring = cur
currep = 1

for each item in vec, starting at vec[1]
  if item==cur
   currep++ // we have a repeat, keep track of how many repetitions
  else 
   // the strings are different,
   if currep > maxrep  // was this repetition count higher than the max
     maxrep=currep     // it is the new max
     maxstring=cur
   cur=item  // next item is current
   currep = 0


GeneralRe: How to find the most frequent value of string array, and how many Pin
sadas232341s20-Nov-11 7:03
sadas232341s20-Nov-11 7:03 
GeneralRe: How to find the most frequent value of string array, and how many Pin
Chris Losinger20-Nov-11 7:20
professionalChris Losinger20-Nov-11 7:20 
GeneralRe: How to find the most frequent value of string array, and how many Pin
sadas232341s20-Nov-11 8:21
sadas232341s20-Nov-11 8:21 
GeneralRe: How to find the most frequent value of string array, and how many Pin
sadas232341s4-May-12 21:27
sadas232341s4-May-12 21:27 
GeneralRe: How to find the most frequent value of string array, and how many Pin
Chris Losinger5-May-12 1:31
professionalChris Losinger5-May-12 1:31 
GeneralRe: How to find the most frequent value of string array, and how many Pin
Randor 20-Nov-11 11:12
professional Randor 20-Nov-11 11:12 
GeneralRe: How to find the most frequent value of string array, and how many Pin
Peter_in_278021-Nov-11 16:33
professionalPeter_in_278021-Nov-11 16:33 
Questionto read a file into an array Pin
robin70019-Nov-11 22:41
robin70019-Nov-11 22:41 
AnswerRe: to read a file into an array Pin
Maximilien20-Nov-11 0:24
Maximilien20-Nov-11 0:24 
AnswerRe: to read a file into an array Pin
Niklas L20-Nov-11 10:06
Niklas L20-Nov-11 10:06 
Questionsocket prograaming doubt! Pin
robin70019-Nov-11 10:04
robin70019-Nov-11 10:04 
AnswerRe: socket prograaming doubt! Pin
Erudite_Eric19-Nov-11 10:30
Erudite_Eric19-Nov-11 10:30 
AnswerRe: socket prograaming doubt! Pin
Albert Holguin19-Nov-11 15:41
professionalAlbert Holguin19-Nov-11 15:41 
QuestionApplication is getting crashed at ShowWndow Pin
Amrit Agr19-Nov-11 3:21
Amrit Agr19-Nov-11 3:21 
AnswerRe: Application is getting crashed at ShowWndow Pin
Chris Losinger19-Nov-11 3:49
professionalChris Losinger19-Nov-11 3:49 
AnswerRe: Application is getting crashed at ShowWndow Pin
Chuck O'Toole19-Nov-11 5:43
Chuck O'Toole19-Nov-11 5:43 
QuestionWhat is differences between a background thread and a modeless dialog? Pin
Member 28839419-Nov-11 0:31
Member 28839419-Nov-11 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.