Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- #include<iomanip>
- using namespace std;
- void read(vector<double>&t)
- {
- double r;
- cout << "Skriv in dina siffror" << endl;
- while( cin >> r)
- t.push_back (r);
- }
- void compute(double minsta, double storsta, double medel, const vector<double>&t)
- {
- double total;
- int h=0;
- for(int i=0; i <= t.size(); i++)
- {
- total=total+t[h];
- h++;
- if (minsta = 0)
- {
- minsta=t[h];
- }
- else if (minsta > t[h])
- {
- minsta=t[h];
- }
- else if (storsta = 0)
- {
- storsta=t[h];
- }
- else if (storsta < t[h])
- {
- storsta=t[h];
- }
- }
- medel=total/h;
- }
- int main()
- {
- vector<double>vec;
- read(vec);
- if (vec.size() < 1)
- cout << "ingen indata" << endl;
- else
- {
- double minsta;
- double storsta;
- double medel;
- compute(minsta, storsta, medel, vec);
- cout << minsta << endl << storsta << endl << medel << endl;
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment