Mavzu: Stack,queue,dequeue(stek,navbat,dek)
Download 246.9 Kb.
|
mtaqqqq
4-LABORATORIYA ISHI Mahmudov jayhun 212-19 6-variant MAVZU: Stack,queue,dequeue(stek,navbat,dek) 6. N ta elementdan tashkil topgan navbat berilgan. Navbatning oxiridagi elementiga teng barcha elementlarni o’chiring. Dastur kodi: #include using namespace std; void showstack(stack { while (!s.empty()) { cout << '\t' << s.top(); s.pop(); }
cout << '\n'; }
int main () {
stack stack s.push(10); s.push(30); s.push(10); s.push(5); s.push(10); s.push(45); s.push(18); s.push(34); s.push(10); cout << "Stek : "; showstack(s); int firstElement = s.top(); k.push(firstElement); while (!s.empty()) { if(s.top() != firstElement) k.push(s.top()); s.pop(); } k.pop();
cout << "Oxirgi elementga teng barcha elementlar ochirilmoqda...\n"; cout << "Stek : "; showstack(k); return 0; } Natija: Download 246.9 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling