|
1 Laboratoriya ishi Guruh: 219 – 22 Fan: Dasturlash Topshirdi: Dehqonov Bekmirza Tekshirdi: Adilbek Yusupbaevich
|
tarix | 19.04.2023 | ölçüsü | 0,73 Mb. | | #100313 |
| bekmirza
O'ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
Muhammad Al-Xorazmiy nomidagi Toshkent Axborot
Texnologiyalari Universiteti
1 - Laboratoriya ishi
Guruh: 219 – 22
Fan: Dasturlash
Topshirdi: Dehqonov Bekmirza
Tekshirdi: Adilbek Yusupbaevich
7 – MISOL
#include
#include
using namespace std;
int main() {
system("cls");
list mylist{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
cout << "boshlang`ich qiymati : ";
for (auto it = mylist.begin(); it != mylist.end(); it++) {
cout << *it << " ";
}
cout << "\njuft elementlari: ";
for (auto it = mylist.begin(); it != mylist.end(); it++) {
if (*it % 2 == 0) {
cout << *it << " ";
}
}
cout << endl;
system("pause");
return 0;
}
7 – MISOL
#include
#include
using namespace std;
int main() {
deque d;
// Ro'yxat elementlarini kiritish
int n;
cout << "Ro'yxat uzunligini kiriting: ";
cin >> n;
int x;
for (int i = 0; i < n; i++) {
cout << i + 1 << "-chi elementni kiriting: ";
cin >> x;
d.push_back(x);
}
// Max va min elementlarni almashtirish
int max_elem = d.front();
int min_elem = d.front();
for (int i = 0; i < d.size(); i++) {
if (d[i] > max_elem) {
max_elem = d[i];
}
if (d[i] < min_elem) {
min_elem = d[i];
}
}
int max_index = distance(d.begin(), find(d.begin(), d.end(), max_elem));
int min_index = distance(d.begin(), find(d.begin(), d.end(), min_elem));
d[max_index] = min_elem;
d[min_index] = max_elem;
// Yangi ro'yxatni chiqarish
cout << "Yangi ro'yxat: ";
for (int i = 0; i < n; i++) {
cout << d[i] << " ";
}
cout << endl;
system("pause");
return 0;
}
Dostları ilə paylaş: |
|
|