MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKЕNT AXBOROT TЕXNOLOGIYALARI UNIVЕRSITЕTI
031-20 guruh talabasi Normuminov Suhrobning Malumotlar tuzilmasi va algoritmlar fanidan
Labaratoriya ishi
TUIT-2022
Ro’yhat har ikkinchi elementi o’chirilsin.
#include
using namespace std;
int main()
{
list num_list;
list :: iterator it;
num_list.push_back(1);
num_list.push_back(2);
num_list.push_back(3);
num_list.push_back(4);
num_list.push_back(5);
cout << num_list.size() << endl;
it = num_list.begin();
advance(it, 1);
for(it; it != num_list.end(); advance(it, 2)) {
num_list.erase(it);
}
for(it = num_list.begin(); it != num_list.end(); ++it) {
cout << *it << " ";
}
cout << endl;
return 0;
}
Do'stlaringiz bilan baham: |