Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL,"Rus");
- vector<int> v;
- int p;
- cout << "Введите кол-во студентов на физре: \n";
- cin >> p;
- for (int i=0; i<p; i++){
- int rost1;
- cout << "Введите рост " << i+1 <<" студента: ";
- cin >> rost1;
- v.push_back(rost1);
- }
- sort(v.begin(), v.end(), greater<int>());
- for (auto x: v){
- cout << x << " ";
- }
- cout<<endl;
- cout << "Введите рост опоздавшего студента: ";
- int rost;
- cin >> rost;
- v.push_back(rost);
- sort(v.begin(), v.end(), greater<int>());
- for (auto x: v){
- cout << x << " ";
- }
- int result;
- for (int i=v.size(); i>=0; i--){
- if(v[i]==rost){
- result=i;
- cout<<endl;
- cout<<"Позиция опоздавшего: "<< i+1; break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement