471,627 Members | 1,590 Online

Comparing numbers and determing the biggest.

Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #1
3 2612
Not sure if there more to your problem that what a simple algorithm might
solve, but here is something that might work. I just threw it together and
so I am not sure if it will work.

public int findLargest( params int[] numSet ){
int largestFound = numSet[0];

// This can be optimized so that first element is not eval since it was
initialized above.
foreach( int num in numSet ){
largestFound = Math.Max(largestFound, num);
}

return largestFound;
}
"esparkman" <ev***********@gmail.com> wrote in message
Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #2
this is a simple approach
i will write psudocode and hope that u can figure it all out
its extremely easy

variable currentNum = 0
variable largestFound = 0

take the very first # assign it to currentNum

while(we have more numbers)
{

if currentNum > largestFound
largestFound = currentNum

}

"esparkman" <ev***********@gmail.com> wrote in message
Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #3
Thanks! Raj you is the man!

That is a much simpler approach.

Nov 30 '05 #4