Click here to Skip to main content
15,922,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: memset() run time error Pin
Stefan_Lang21-Nov-11 22:37
Stefan_Lang21-Nov-11 22:37 
QuestionCIPAddressCtrl background color Pin
Benjamin Bruno21-Nov-11 0:48
Benjamin Bruno21-Nov-11 0:48 
AnswerRe: CIPAddressCtrl background color Pin
Randor 21-Nov-11 3:22
professional Randor 21-Nov-11 3:22 
AnswerRe: CIPAddressCtrl background color Pin
Satheesh154621-Nov-11 17:40
Satheesh154621-Nov-11 17:40 
Questionstring operation Pin
robin70020-Nov-11 19:21
robin70020-Nov-11 19:21 
AnswerRe: string operation Pin
«_Superman_»20-Nov-11 21:52
professional«_Superman_»20-Nov-11 21:52 
AnswerRe: string operation Pin
vr99999999921-Nov-11 1:53
vr99999999921-Nov-11 1:53 
QuestionRe: string operation Pin
David Crow21-Nov-11 2:06
David Crow21-Nov-11 2:06 
QuestionRe: string operation Pin
CPallini21-Nov-11 2:07
mveCPallini21-Nov-11 2:07 
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 
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 
It's not working. Gives me "zxc" and 1, but the correct is "qwe" and 3.

C++
int main()
{
	string str[8] = {"zxc", "zxc", "asd", "qwe", "qwe", "asd", "qwe", "jkl"};
	vector<string> v_str;
	string t_str, maxstring;
	int maxrep = 1;
	int currep = 1;

	for(int i = 0; i < 8; i++)
		v_str.push_back(str[i]);

	for(int i = 1; i < v_str.size(); i++)
		for(int j = v_str.size() - 1; j >= i; j--)
			if(v_str[j - 1] > v_str[j])
			{
				t_str = v_str[j - 1];
				v_str[j - 1] = v_str[j];
				v_str[j] = t_str;
			}

	t_str = v_str[0];
	maxstring = t_str;

	for(int i = 1; i < v_str.size(); i++)
	{
		if(v_str[i] == t_str)
			currep++;
		else if(currep > maxrep)
		{
			maxrep = currep;
			maxstring = t_str;
		}

		t_str = v_str[i];
		currep = 0;
	}

	for(int i = 0; i < v_str.size(); i++)
		cout << v_str[i] << endl;

	cout << endl;

	cout << t_str << endl;
	cout << maxrep << endl;

	return 0;
}

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 

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.