Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <algorithm>
- #include <sstream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main() {
- string cons;
- string input;
- stringstream ss;
- double value;
- bool strict = false;
- bool integers_only = false;
- int count = 0;
- vector<double> numbers;
- while(getline(cin, input) && input != "END") {
- if(count == 0) {
- if(input.find("strict") >= 0 && input.find("strict") <= 50) {
- strict = true;
- }else if(input.find("integers-only") >= 0 && input.find("integers-only") <= 50) {
- integers_only = true;
- }else if(input.find("strict:integers-only") >= 0 && input.find("strict:integers-only") <= 50) {
- strict = true;
- integers_only = true;
- }
- }
- ss << input;
- while(!ss.eof()) {
- if(ss >> value) {
- numbers.push_back(value);
- count++;
- }else if(ss.fail()) {
- ss.clear();
- string fail;
- ss >> fail;
- continue;
- }
- }
- ss.str(string());
- ss.clear();
- }
- double min = numbers[0];
- double max = numbers[0];
- double sum;
- double average;
- int counter = 0;
- for (auto i = numbers.begin(); i != numbers.end(); ++i) {
- if(*i > max) {
- max = *i;
- }
- if(*i < min) {
- min = *i;
- }
- sum += *i;
- counter++;
- }
- average = sum / counter;
- double rounded_avr = roundf(average * 100) / 100;
- cout << min << ' ';
- cout << max << ' ';
- cout << setprecision(4) << average << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement