Click here to Skip to main content
15,888,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Notification in Multi CListBox Pin
002comp24-Nov-10 1:58
002comp24-Nov-10 1:58 
QuestionRe: Notification in Multi CListBox [modified] Pin
CPallini24-Nov-10 2:15
mveCPallini24-Nov-10 2:15 
AnswerRe: Notification in Multi CListBox Pin
002comp24-Nov-10 19:30
002comp24-Nov-10 19:30 
Questionwhat data type use in String concatination function in vc++ DLL? Pin
mathivanaan23-Nov-10 17:22
mathivanaan23-Nov-10 17:22 
AnswerRe: what data type use in String concatination function in vc++ DLL? Pin
KingsGambit23-Nov-10 17:51
KingsGambit23-Nov-10 17:51 
AnswerRe: what data type use in String concatination function in vc++ DLL? Pin
S Houghtelin24-Nov-10 4:30
professionalS Houghtelin24-Nov-10 4:30 
GeneralRe: what data type use in String concatination function in vc++ DLL? Pin
meaningoflights24-Nov-10 17:42
meaningoflights24-Nov-10 17:42 
QuestionSort Functions Pin
Babylon Lion23-Nov-10 8:18
Babylon Lion23-Nov-10 8:18 
Hi all,
I have a working program that reads stocks symbols and values from a text file and do some operations on the data, and then it outputs the the data as two reports. The first report is sorted by stock symbols, and the other report is sorted by percent gain/loss.
I'm having difficulties understating how these sort functions are doing the comparisons..
Can you guys provide some explanation please?

//sorts the stocks naturally (stock symbol)
template<class elemType>
void listType<elemType>::sort(){  
	int i, j;
	int min;
	elemType  temp;

	for (i = 0; i <length; i++){
		min = i;
		for (j = i + 1; j < length; ++j)
		   if (list[j] < list[min])
			min = j;
		temp = list[i];
		list[i] = list[min];
		list[min] = temp;
	}
}


//sorts the stocks by percent gain/loss
void stockListType::sortByGain(){
	int i, j;
	int  temp;
	indexByGain = new int[length];

	//Pre-populate the index array
	for(int c = 0; c < length; c++){
		indexByGain[c] = c;
	}

	//Sort by the percentage change
	for (i = 0; i <length; i++){
		for (j = i + 1; j < length; j++){
		   if (list[indexByGain[j]].getPercentChange() > list[indexByGain[i]].getPercentChange()){
				temp = indexByGain[i];
				indexByGain[i] = indexByGain[j];
				indexByGain[j] = temp;
		   }
		}
	}
}

AnswerRe: Sort Functions Pin
«_Superman_»23-Nov-10 8:32
professional«_Superman_»23-Nov-10 8:32 
AnswerRe: Sort Functions Pin
David Crow23-Nov-10 8:39
David Crow23-Nov-10 8:39 
GeneralRe: Sort Functions Pin
Babylon Lion23-Nov-10 10:11
Babylon Lion23-Nov-10 10:11 
GeneralRe: Sort Functions Pin
CurtainDog23-Nov-10 21:12
CurtainDog23-Nov-10 21:12 
AnswerRe: Sort Functions Pin
CPallini23-Nov-10 9:24
mveCPallini23-Nov-10 9:24 
GeneralRe: Sort Functions Pin
Babylon Lion23-Nov-10 9:44
Babylon Lion23-Nov-10 9:44 
GeneralRe: Sort Functions Pin
CPallini23-Nov-10 10:06
mveCPallini23-Nov-10 10:06 
GeneralRe: Sort Functions Pin
S Houghtelin24-Nov-10 4:07
professionalS Houghtelin24-Nov-10 4:07 
AnswerUse QuickSort Pin
DarthDana24-Nov-10 4:20
professionalDarthDana24-Nov-10 4:20 
GeneralRe: Use QuickSort Pin
Maximilien24-Nov-10 5:42
Maximilien24-Nov-10 5:42 
GeneralRe: Use QuickSort Pin
Matthew Barnett24-Nov-10 5:46
Matthew Barnett24-Nov-10 5:46 
GeneralRe: Use QuickSort Pin
«_Superman_»24-Nov-10 7:30
professional«_Superman_»24-Nov-10 7:30 
GeneralRe: Use QuickSort Pin
ThatsAlok11-Jul-11 21:18
ThatsAlok11-Jul-11 21:18 
AnswerRe: Sort Functions Pin
James Lonero24-Nov-10 9:00
James Lonero24-Nov-10 9:00 
AnswerRe: Sort Functions Pin
dpminusa24-Nov-10 13:32
dpminusa24-Nov-10 13:32 
AnswerRe: Sort Functions Pin
James Curran28-Nov-10 5:18
James Curran28-Nov-10 5:18 
QuestionCButton question Pin
DerrekCurtis23-Nov-10 7:09
DerrekCurtis23-Nov-10 7:09 

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.