my output is not coming i checked my code twice but couldn’t find a mistake please help
My output is not coming
#include
#include
using namespace std;
void transfer(stack& s1 , stack &s2 , int n){ // i have written int but its not showing here
for (int i = 0; i < n; i++) {
s2.push(s1.top());
s1.pop();
}
}
void reverse_stack(stack &s1){
// helper stack
stack s2;
int n = s1.size();
for (int i = 0; i < n; i++) {
//pick the element and insert at bottom
int x = s1.top();
s1.pop();
//transfer n-i-1 elements from s1 to s2
transfer(s1,s2,n-i-1);
//insert the element x in s1
s1.push(x);
// transfer n-i-1 elements from s2 to s1
transfer(s2,s1,n-i-1);
}
}
int main()
{
stack s;
s.push(1);
s.push(2);
s.push(3);
s.push(4);
cout<<"before reversing"<<endl;
while(!s.empty()){
std::cout << s.top()<< " ";
s.pop();
}
cout<<endl;
cout<<"after reversing"<<endl;
reverse_stack(s);
while(!s.empty()){
std::cout << s.top()<< " ";
s.pop();
}
return 0;
}
i have shared the code above
Big codes are not readable here
i have shared the code
can u see the code???
can u see my code now plzz ansswer??
no share the link here
as i click on share button no link generates what shall i send u?
shall i share the code on whatsapp?
Save the code and then share the url of that page
i have shared that above
Buddy u didn’t saved the code I’m seeing default hello world code …write, save (ctrl +s),share the url
are you able to see now?
please reply…
Yes, it’s visible now
plz check and tell the mistake
