Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- using namespace std;
- void Sort(int* mas, int n) //Сортировка пузырьком
- {
- for (int i = 0; i < n; ++i)
- for (int j = i + 1; j < n; ++j)
- if (mas[j] > mas[i])
- swap(mas[i], mas[j]); //Меняем местами mas[i] и mas[j]
- }
- int main()
- {
- int n, *mas, x;
- cin >> n;
- mas = new int[n]; //Создаем динамический массив из n элементов
- for (int i = 0; i < n; i++) {
- cin >> mas[i];
- }
- cin >> x;
- Sort(mas, n); //Сортируем полученные данные по убыванию (студенты выстраиваются по росту)
- for (int i = 0; i < n; i++) {
- if (x > mas[i]) { //Проверка на случай, если нету одинакового роста
- cout << endl << "Res = " << i + 1;
- break;
- }
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement