phinfanfrommd

10-19-2006, 01:21 AM

how would I find the smallest and largest numbers of an array of 10 integers? take it easy on me im no expert.

View Full Version : c++ concept i cant grasp

phinfanfrommd

10-19-2006, 01:21 AM

how would I find the smallest and largest numbers of an array of 10 integers? take it easy on me im no expert.

King Felix

10-19-2006, 01:24 AM

i'm lost :confused:

phinfanfrommd

10-19-2006, 01:27 AM

do you know any c++?

Nappy Roots

10-19-2006, 01:28 AM

its ****in simple

phinfanfrommd

10-19-2006, 01:29 AM

thanks i know it is

im just starting out give me a break

im just starting out give me a break

phinfanfrommd

10-19-2006, 01:29 AM

i dont need teh actualy code just the concept

Nappy Roots

10-19-2006, 01:32 AM

thanks i know it is

im just starting out give me a break

i was kiddin, i have noooooooo clue what your talkin about.

im just starting out give me a break

i was kiddin, i have noooooooo clue what your talkin about.

Dol-Fan Dupree

10-19-2006, 02:44 AM

off the top of my head a really simple solution would be have an integer value high and an integer value low. Set the low to the highest integer value and the high to the lowest. Then travse the array with a for loop. Like from i = 10 (or MAX_SIZE); i = 0; i++

Then check if a[i] > high then high equals i and also check if a[i] < low then low equals i.

There is probably a better way to do it, but I am too tired to think about it.

Then check if a[i] > high then high equals i and also check if a[i] < low then low equals i.

There is probably a better way to do it, but I am too tired to think about it.

ChrisKo

10-19-2006, 12:22 PM

off the top of my head a really simple solution would be have an integer value high and an integer value low. Set the low to the highest integer value and the high to the lowest. Then travse the array with a for loop. Like from i = 10 (or MAX_SIZE); i = 0; i++

Then check if a[i] > high then high equals i and also check if a[i] < low then low equals i.

There is probably a better way to do it, but I am too tired to think about it.

That would work.

You could also use any of the sorting routines (bubble, quick, btree, etc) and once the array has been sorted, the first and last elements are your needed values.

Then check if a[i] > high then high equals i and also check if a[i] < low then low equals i.

There is probably a better way to do it, but I am too tired to think about it.

That would work.

You could also use any of the sorting routines (bubble, quick, btree, etc) and once the array has been sorted, the first and last elements are your needed values.

phinfanfrommd

10-20-2006, 12:19 AM

That would work.

You could also use any of the sorting routines (bubble, quick, btree, etc) and once the array has been sorted, the first and last elements are your needed values.

wow that is much more efficient, im looking at it in my book now, sounds a little to complex for my simple solution. thanks though!

You could also use any of the sorting routines (bubble, quick, btree, etc) and once the array has been sorted, the first and last elements are your needed values.

wow that is much more efficient, im looking at it in my book now, sounds a little to complex for my simple solution. thanks though!

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.