Faqts : Business : Programming : Shopping For You : C++

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 15 people (20%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

C++: Array: Minimum: How to find the minimum in array? Dimension: 1: Standard Template Library (STL)

Aug 28th, 2009 12:51
Knud van Eeden, Joe Bloggs,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 February 2006 - 02:52 pm -------------------

C++: Array: Minimum: How to find the minimum in array? Dimension: 1: 
Standard Template Library (STL)

--- cut here: begin --------------------------------------------------

#include <iostream>
//
#include <vector.h>
//
using namespace std;
//
int main() {
 //
 // --- Declare a vector.
 //
 vector <double> v;
 //
 // --- Read numbers into it.
 //
 v.push_back( 1 );
 v.push_back( 2 );
 v.push_back( 3 );
 v.push_back( 4 );
 v.push_back( 5 );
 v.push_back( 6 );
 //
 // --- Search for minimum value
 //
 double minValue = v[ 0 ];
 //
 for ( int I = 0; I <= v.size() - 1; I++ ) {
  if ( minValue > v[ I ] ) {
   minValue = v[ I ];
  }
 }
 cout << "minimum = ";
 cout << minValue;
 cout << endl;
//
}

--- cut here: end ----------------------------------------------------

===

Internet: see also:

---

Computer: Language: Compiler: C++: Array: Link: Can you give an 
overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/39794/fid/163

----------------------------------------------------------------------