Advertisement
Guest User

занятие 25.04.19

a guest
Apr 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <iostream> // Для консольного ввода вывода
  2. #include <vector> //Для использования векторов (динамических массивов)
  3. #include "windows.h"
  4. #include <ctime> //Таймер для генератора случайных чисел
  5. #include <algorithm>
  6. #include <set>
  7.  
  8. using namespace std; // Пространство имён по умолчанию
  9.  
  10.  
  11. bool MyFind(string text, char templ)
  12. {
  13.     int i = 0;
  14.     for (; i < text.length(); i++)
  15.     {
  16.         if (text[i] == templ)
  17.         {
  18.             return true;
  19.         }
  20.        
  21.     }
  22.     return false;
  23. }
  24.  
  25.  
  26.  
  27. int MyInt(int& y)
  28. {
  29.     return y = y*y;
  30. }
  31.  
  32. void MySort(vector<int>& h)
  33. {
  34.     int i = 0, min = 0, numb, j;
  35.     for (i = 0; i < h.size(); i++)
  36.     {
  37.         for (j = i + 1; j < h.size(); j++)
  38.         {
  39.             if (h[i] < h[j])
  40.             {
  41.                 //swap(h[i], h[j]);
  42.                 min = h[j];
  43.                 h[j] = h[i];
  44.                 h[i] = min;
  45.  
  46.             }
  47.         }
  48.     }
  49. }
  50.  
  51.  
  52. int main()
  53. {
  54.  
  55.  
  56.     freopen("input.txt", "r", stdin);
  57.     freopen("output.txt", "w", stdout);
  58.    
  59.     srand(time(0)); //Начинаем генерировать последовательность случайных чисел, в зависимости от текущего времени
  60.  
  61.  
  62.     /*string s, q = "";
  63.     while (cin >> s)
  64.     {
  65.         q = q + s;
  66.         if (MyFind(q, 'p')) cout << "yes\n";
  67.         else cout << "no\n";
  68.     }*/
  69.  
  70.     int i = 5,j;
  71.     j = MyInt(i);
  72.     //cout << i;
  73.  
  74.     vector <int> v;
  75.     int  min = 0, numb;
  76.     while (cin >> numb)
  77.     {
  78.         v.push_back(numb);
  79.     }
  80.     MySort(v);
  81.  
  82.     for (auto it : v) cout << it << " ";
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement