Navbat eng kichik elementi o„chirilsin
Download 101.75 Kb.
|
9-Amaliyot. (Navbat)
TopshiriqNavbat eng kichik elementi o„chirilsin. #include #include using namespace std; int main(){ int n,max1 = INT_MIN; cin>>n; queue int maxi; for (int i=1; i<=n; i++){ int k; cin>>k; a.push(k); max1 = max(max1,k); if (max1 == k) maxi = i; } int d=1; while (!a.empty()){ if (d!=maxi){ b.push(a.front()); } a.pop(); d++; } while (!b.empty()){ cout< } } Navbatda birinchi elementga teng barcha elementlar o„chirilsin. #include #include using namespace std; int main(){ int n,max1 = INT_MIN; cin>>n; queue int maxi; for (int i=1; i<=n; i++){ int k; cin>>k; a.push(k); } int birinchi = a.front(); int d=1; while (!a.empty()){ if (a.front()!=birinchi){ b.push(a.front()); } a.pop(); d++; } while (!b.empty()){ cout< } } Navbatda oxirgi elementga teng barcha elementlar o„chirilsin. #include #include using namespace std; int main(){ int n; cin>>n; queue for (int i=1; i<=n; i++){ int k; cin>>k; a.push(k); } int oxirgi = a.back(); while (!a.empty()){ if (a.front()!=oxirgi){ b.push(a.front()); } a.pop(); } while (!b.empty()){ cout< } } Navbat eng katta elementi o„chirilsin. #include #include using namespace std; int main(){ int n,max1 = INT_MIN; cin>>n; queue int maxi; for (int i=1; i<=n; i++){ int k; cin>>k; a.push(k); max1 = max(max1,k); if (max1 == k) maxi = i; } int d=1; while (!a.empty()){ if (d!=maxi){ b.push(a.front()); } a.pop(); d++; } while (!b.empty()){ cout< } } Download 101.75 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling