2-Amaliyot ishi ishlanmalari Amaliy mashgulot
Download 81.82 Kb.
|
21-variant
2-Amaliyot ishi ishlanmalari Amaliy mashgulot. Kontеynеrlar (Kollеksiyalar) uchun amaliyot topshiriqlari uchun ishlanma va na’munalar. 21-variant Array ning max elementi va min elementini toping. #include #include #include using namespace std; int main() { array auto max_it = max_element(array.begin(), array.end()); cout << "Maksimal element: " << *max_it << '\n'; auto min_it = min_element(array.begin(), array.end()); cout << "Minimal element: " << *min_it << '\n'; return 0; }
listning har 2 ta elementidan keyin ularning yig‘indisini joylang. #include #include using namespace std; int main() { list list for (auto it = my_list.begin(); it != prev(my_list.end()); advance(it, 2)) { int sum = *it + *next(it); new_list.push_back(*it); new_list.push_back(*next(it)); new_list.push_back(sum); if (next(next(it)) == my_list.end()) { break; } } new_list.push_back(my_list.back()); for (auto it = new_list.begin(); it != new_list.end(); ++it) { cout << *it << " "; } cout << endl; return 0; } Download 81.82 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling