-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (38 loc) · 1.15 KB
/
Copy pathmain.cpp
File metadata and controls
44 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
string choice;
double sum {};
double mean {};
vector <int> vec{10,10,5,1,2,3};
int app{};
do{
cout<<"\nP - Print numbers\nA - Add a number\nM - Display mean of the numbers\nS - Display the smallest number\nL - Display the largest number\nQ - Quit"<<endl;
cin>>choice;
if (choice=="P" || choice=="p")
for (int a:vec)
cout<<a<<" ";
if (choice=="A" || choice=="a") {
cout << "Type number: " << endl;
cin >> app;
vec.push_back(app);
}
if (choice=="M" || choice=="m") {
for (int a:vec){
sum+=a;
mean=sum/vec.size();
}
cout<<"The mean is "<<mean<<endl;
}
if (choice=="S" || choice=="s"){
cout<<"Min element: "<<*min_element(vec.begin(),vec.end());
}
if (choice=="L" || choice=="l"){
cout<<"Max element: "<<*max_element(vec.begin(),vec.end());
}
}while(choice!="q" && choice!="Q");
cout<<"Goodbye";
return 0;
}