MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI 006_1-GURUH TALABASI
ADILOV ELDORNING DASTURLASH II FANIDAN
1-LABARATORIYA ISHI
Fan o’qituvchisi:
Fayzullaeva Zarnigor
1-topshiriq
Navbatda birinchi va oxirgi elementlar orni almashtirilsin.
KODI
#include #include #include using namespace std;
int main() {
int arr[] = {1, 2, 3, 4, 5};
stack stk;
queue q;
for (int i = 0; i < 5; i++) {
stk.push(arr[i]);
q.push(arr[i]);
}
int first = q.front();
int last = stk.top();
stk.pop();
stk.push(first);
q.pop();
q.push(last);