Online Shopping : Computers : Programming : Languages : C++

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

2 of 12 people (17%) 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)

Feb 22nd, 2006 07:34
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 February 2021 - 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
----------------------------------------------------------------------