
C/C++
Помогите с С++ пожалуйста
Контейнер Тип элементов Задание 1 Задание 2 Задание 3


// 1 задание
#include <iostream>
#include <set>
#include <random>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << x << ' ';
puts("");
box.erase(box.begin());
for (auto& x : box) cout << x << ' ';
puts("");
system("pause > nul");
}
// 2 задание
#include <iostream>
#include <set>
#include <random>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int, greater<>> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << x << ' ';
puts("");
box.erase(box.begin());
for (auto& x : box) cout << x << ' ';
puts("");
system("pause > nul");
}
// 3 задание
#include <algorithm>
#include <iostream>
#include <set>
#include <random>
#include <iomanip>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << setw(5) << x << ' ';
puts("");
auto [pmin, pmax] = minmax_element(box.begin(), box.end());
auto sub = *pmax - *pmin;
cout << " max: " << *pmax << "\n min: " << *pmin << "\n difference: " << sub << '\n';
multiset<int> tmp;
for (auto& x : box) tmp.emplace(x - sub);
box = tmp;
for (auto& x : box) cout << setw(5) << x << ' ';
puts("");
system("pause > nul");
}
#include <iostream>
#include <set>
#include <random>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << x << ' ';
puts("");
box.erase(box.begin());
for (auto& x : box) cout << x << ' ';
puts("");
system("pause > nul");
}
// 2 задание
#include <iostream>
#include <set>
#include <random>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int, greater<>> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << x << ' ';
puts("");
box.erase(box.begin());
for (auto& x : box) cout << x << ' ';
puts("");
system("pause > nul");
}
// 3 задание
#include <algorithm>
#include <iostream>
#include <set>
#include <random>
#include <iomanip>
using namespace std;
int main() {
uniform_int_distribution<> uid(10, 25);
mt19937 gen{ random_device()() };
const auto n = 15U;
multiset<int> box;
for (auto i = 0U; i < n; ++i) box.emplace(uid(gen));
for (auto& x : box) cout << setw(5) << x << ' ';
puts("");
auto [pmin, pmax] = minmax_element(box.begin(), box.end());
auto sub = *pmax - *pmin;
cout << " max: " << *pmax << "\n min: " << *pmin << "\n difference: " << sub << '\n';
multiset<int> tmp;
for (auto& x : box) tmp.emplace(x - sub);
box = tmp;
for (auto& x : box) cout << setw(5) << x << ' ';
puts("");
system("pause > nul");
}
Дим Ооо Юеи
mojno без auto пожалуйста, заменить
Похожие вопросы
- Помогите решить задачу пожалуйста, в C++
- Помогите с кодом, пожалуйста
- Язык Си.помогите написать формулу пожалуйста
- Помогите в С++ пожалуйста
- Помогите решить задачу пожалуйста С++
- Помогите с c++ пожалуйста
- Помогите изменить задачу пожалуйста немного
- Помогите решить задачу, пожалуйста. (Язык Си)
- Помогите решить задачу, пожалуйста. Сам не понимаю. (Язык Си)
- Помогите решить С++ пожалуйста