001
03.04.2003, 15:17 Uhr
typecast
aka loddab (Operator)
|
#include <iostream> using std::cout; using std::cin; using std::endl;
#include <algorithm> using std::max_element; using std::min_element;
#include <numeric> using std::accumulate;
#include <vector> using std::vector;
int main() { cout << "Bitte eine Reihe von Zahlen eingeben: "; double zahl; vector<double> v; while (cin >> zahl) v.push_back(zahl); double min = *min_element(v.begin(), v.end()); double max = *max_element(v.begin(), v.end()); double average = accumulate(v.begin(), v.end(), 0.0) / v.size();
cout << "Minimum der Zahlen: " << min << endl << "Maximum der Zahlen: " << max << endl << "Durchschnitt : " << average << endl; } -- All parts should go together without forcing. ... By all means, do not use a hammer. (IBM maintenance manual, 1925) |