Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 3
- Вектора
- */
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- vector<double> vec;
- cout << "Vvodite chisla, v konce nazhmite Ctrl+Z:" << endl;
- double a, mx, mn;
- int mxCnt = 1, mnCnt = 1;
- cin >> a;
- vec.push_back(a);
- mx = vec[0];
- mn = vec[0];
- while(cin >> a){
- vec.push_back(a);
- if(a > mx){
- mx = a;
- mxCnt = 1;
- continue;
- }
- if(a == mx){
- mxCnt++;
- }
- if(a < mn){
- mn = a;
- mnCnt = 1;
- continue;
- }
- if(a == mn){
- mnCnt++;
- }
- }
- cout << "Max is: " << endl;
- if(mxCnt == 1){
- cout << mx << endl;
- }else{
- cout << mxCnt << "x " << mx << endl;
- }
- cout << "Min is: " << endl;
- if(mnCnt == 1){
- cout << mn << endl;
- }else{
- cout << mnCnt << "x " << mn << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment