Reverse a stack

All test cases failed.
Didn’t understand the output format.
Was it really reversed??

@prashantverma.vn Yes the stack was reversed. The last element of the input is the topmost element of the stack . So when you are giving the output this topmost element is popped at last because the stack has reversed.
You need to print the output order of the stack.
So if you do it with array it should look like this

for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cout<<a[i]<<endl;

int main() {
stack<int> s;
int n;
cin>>n;
for(int i=1; i<=n; i++){
    s.push(i);
}
reverse(s);
while(!s.empty()){
    cout<<s.top()<<endl;
    s.pop();
}
return 0;

}
This is my main function.
Can you please help me in correcting this??
How can the reverse function accept an array as input instead of stack??

You need to use 2 stacks . Try to use this algo

First Empty your stack into another helper Stack.
Then Using Recursion copy element from helper to stack.
Till the Stack is reversed.