Laitofai

Untitled

Nov 23rd, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. /*
  2.              3
  3.           Вектора
  4. */
  5. #include <iostream>
  6. #include <vector>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     vector<double> vec;
  14.     cout << "Vvodite chisla, v konce nazhmite Ctrl+Z:" << endl;
  15.     double a, mx, mn;
  16.     int mxCnt = 1, mnCnt = 1;
  17.     cin >> a;
  18.     vec.push_back(a);
  19.     mx = vec[0];
  20.     mn = vec[0];
  21.     while(cin >> a){
  22.         vec.push_back(a);
  23.         if(a > mx){
  24.             mx = a;
  25.             mxCnt = 1;
  26.             continue;
  27.         }
  28.         if(a == mx){
  29.             mxCnt++;
  30.         }
  31.         if(a < mn){
  32.             mn = a;
  33.             mnCnt = 1;
  34.             continue;
  35.         }
  36.         if(a == mn){
  37.             mnCnt++;
  38.         }
  39.     }
  40.     cout << "Max is: " << endl;
  41.     if(mxCnt == 1){
  42.         cout << mx << endl;
  43.     }else{
  44.         cout << mxCnt << "x " << mx << endl;
  45.     }
  46.  
  47.     cout << "Min is: " << endl;
  48.     if(mnCnt == 1){
  49.         cout << mn << endl;
  50.     }else{
  51.         cout << mnCnt << "x " << mn << endl;
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment