Stack (display integer that push onto stack with its size)

input : 2 //(number of case)
4 5 6 0
output : 3: 6 5 4 0
input : 1 2 3 0
output : 3: 3 2 1 0

#include <iostream>
#include <stack>

using namespace std;

int main()
{
int k=0 ,j=0, num, Case ;
stack<int> myStack;

cin>>Case;
while(j<Case)

{
k=0;
cout<<endl;
cin>>num;

while(num!=0)
{

k++;
myStack.push(num);
cin>>num;
}

cout<<endl;
cout<<k<<" : ";

while (!myStack.empty())
{
cout<<myStack.top()<<" ";
myStack.pop();
}

j++;
}

return 0;

}
Please edit your post and use code tags - http://www.cplusplus.com/articles/jEywvCM9/

Also please ask a specific question.
Topic archived. No new replies allowed.