![]() |
|
#1
|
|||
|
|||
How to find the minimum value in this array?Hi there,
Assume there is an array called arr with the following defintiion: int arr[5] = {23, 4, 344, 30, 23}; I need to find out the what is the minimum value is. In this case the values are visible, assume the values are not visble. The only way i know is to do a bubble sort. But I cannot do a bubble sort becuase i need to find out the actual index value of the minmum number.If i do a bubble sort in the ascending order then it is obviouse the minimum value is in the index 0. But That it not it's actual position. In the above array the minimm value is "4" and the position is 1. But if we dont know the minimum value and where it is, How do we find out what is the minimum value and it's location in the array WITHOUT doing a bubble sort? cheers |
|
#2
|
|||
|
|||
Re: How to find the minimum value in this array?CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: How to find the minimum value in this array?You just need to set the first element of array as minimum, then compare one by one.
__________________
Linux is the best OS in the world. |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| where is the problem and can you fix it (php) | oggie | MySQL / PHP Forum | 8 | 14-Apr-2008 15:08 |
| Getting a line error in register | oggie | MySQL / PHP Forum | 5 | 13-Apr-2008 16:16 |
| Logic error with recursion to find smallest in an array | aijazbaig1 | MS Visual C++ / MFC Forum | 4 | 13-Jul-2006 08:32 |
| Need help deleting the last element in the array | headphone69 | CPP / C++ Forum | 2 | 15-Mar-2006 19:31 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The