4-Amaliy ish 2-variant N ta elementdan tashkil topgan navbat berilgan. Navbatning o’rtadagi elemntini o’chiring. #include using namespace std;
void deleteMiddle(stack &s, int n,int current)
{
if (s.empty() || current == n)
return;
int x = s.top();
s.pop();
deleteMiddle(s, n, current+1);
if (current != n/2)
s.push(x);
}
int main()
{
stack s;
s.push(5);
s.push(6);
s.push(7);
s.push(8);
s.push(9);
s.push(10);
s.push(11);
int current = 0;
deleteMiddle(s, s.size(),current);
while (!s.empty())
{
int p = s.top();
s.pop();
cout << p << " ";
}
return 0;