Bajardi: ALMAMATOV JAVLONBEK(SWD008-1) TOSHKENT 2023
4-topshiriq N ta elementdan tashkil topgan navbat berilgan.navbatning eng kichik elementini toping va bu elelementni 0 bilan almashtiring.
Dastur kodi #include #include #include using namespace std;
int findMinimumElement(queue& q) { int minimum = q.front(); while (!q.empty()) { int current = q.front(); if (current < minimum) { minimum = current; } q.pop(); } return minimum; }
void replaceWithZero(queue& q, int target) { deque temp; while (!q.empty()) { int current = q.front(); q.pop(); if (current == target) { temp.push_back(0); } else { temp.push_back(current); } } for (int i = 0; i < temp.size(); i++) { q.push(temp[i]); } }