-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path301.cpp
More file actions
39 lines (36 loc) · 707 Bytes
/
Copy path301.cpp
File metadata and controls
39 lines (36 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// { Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
char* reverse(char *str, int len);
int main()
{
long long int t;
cin>>t;
while(t--)
{
char str[10000];
cin>>str;
long long int len=strlen(str);
char *ch=reverse(str,len);
for(int i=0;i<len;i++)
{
cout<<ch[i];
}
cout<<endl;
}
return 0;
}
// } Driver Code Ends
//return the address of the string
char* reverse(char *S, int len)
{
stack<char> s;
for(int i=0;i<len;i++){
s.push(S[i]);
}
for(int i=0;i<len;i++){
S[i]=s.top();
s.pop();
}
return S;
}