Deque oxirgi 5 ta elementlarini o’chirilsin
Download 30.4 Kb.
|
Deque oxirgi 5 ta elementlarini o’chirilsin. #include #include using namespace std; void removeLastFive(deque { int n = d.size(); if (n <= 5) { d.clear(); } else { for (int i = 0; i < 5; i++) { d.pop_back(); } } } int main() { deque removeLastFive(d); while (!d.empty()) { cout << d.front() << " "; d.pop_front(); } cout << endl; return 0; } Ro’yxat berilgan ekrandan kirtilgan sonning toq qiymatdagi elementlarini ekranga chiqaring. #include #include #include using namespace std; int main() { srand(time(0)); int n, j = 0; cout << "Ro'yhat elementlari soni: "; cin >> n; list for (int j = 0; j < n; j++) { a.push_back(rand() % 50 - 20); } for (auto i = a.begin(); i != a.end(); i++) { cout << *i << " "; } cout << endl; for (auto i = a.begin(); i != a.end(); i++) { if (*i % 2 != 0) { cout << *i << " "; } } cout << endl; _getwch(); return 0; } Download 30.4 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling