O’zbekistonRespublikasiAxborot Texnologiyalari va Kommunikatsiyalarini
Download 0.81 Mb.
|
Stek o‘rtasidagi element o‘chirib tashlansin. Agar stek elementi
O’zbekistonRespublikasiAxborot Texnologiyalari va Kommunikatsiyalarini RivojlantirishVazirligi Muhammad Al-XorazmiyNomidagi Toshkent AxborotTexnologiyalariUniversiteti Variant 14: Bajardi:Mamaraimov Elyor Tekshirdi: Saidov.S
#include #include usingnamespacestd; voiddeleteMid_util(stack { if(current==sizeOfStack/2) { s.pop(); return; } intx = s.top(); s.pop(); current+=1; deleteMid_util(s,sizeOfStack,current); s.push(x); } voiddeleteMid(stack { deleteMid_util(s,sizeOfStack,0); } intmain() { stack st.push('1'); st.push('2'); st.push('3'); st.push('4'); st.push('5'); st.push('6'); st.push('7'); st.push('8'); deleteMid(st, st.size()); while (!st.empty()) { charp=st.top(); st.pop(); cout<} return0; } #include #include #include #include usingnamespacestd; voiddeleteMid_util(stack { intm = sizeOfStack / 2; stack charx = 'a'; for (intn = sizeOfStack - 1; n != m - 2; n--) { x = s.top(); s.pop(); if (sizeOfStack % 2 == 0&&n>m) { st1.push(x); } elseif (sizeOfStack % 2 == 1&&n != m) { st1.push(x); } } cout< x = st1.top(); st1.pop(); s.push(x); } } intmain() { srand(time(0)); stack intn; cin>>n; for (inti = 0; i } deleteMid_util(st, st.size()); while (!st.empty()) { intp = st.top(); st.pop(); cout<} return0; } Download 0.81 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling