5-LABARATORIYA ISHI
Vafoqulova Gavhar 22-VARIANT
22. Ro’yhat yarating, Ro’yhatga N ta haqiqiy son kiriting. Ro’yhatning maksimum elementini o’chirish dasturini tuzing.
DASTUR KODI ::
#include
#include
using namespace std;
int main()
{
list L, L1;
list::iterator it;
int n, max;
cout << "Elementlar soni : ";
cin >> n;
for (int i = 0, x; i < n; i++)
{
cin >> x;
L.push_back(x);
}
max = *(L.begin());
for (it = L.begin(); it != L.end(); it++)
{
if (*it > max)
max = *it;
}
for (it = L.begin(); it != L.end(); it++)
{
if (max == *it)
continue;
L1.push_back(*it);
}
cout << "Royhatning max elementi : " << max << "\n\n";
cout << "Royhat...\n";
for(it=L1.begin();it!=L1.end();it++)
cout<<" "<<*it<<" ";
system("pause");
return 0;
}
Do'stlaringiz bilan baham: |