471,627 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

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
news:11**********************@g14g2000cwa.googlegr oups.com...
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
raj
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
currentNum = read next number

}

"esparkman" <ev***********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by lallous | last post: by
89 posts views Thread by purifier | last post: by
45 posts views Thread by bobalong | last post: by
30 posts views Thread by vim | last post: by
5 posts views Thread by soeren | last post: by
27 posts views Thread by Thomas Kowalski | last post: by
5 posts views Thread by saneman | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.