Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int len; char temp;
- cin>>len;
- cin.ignore();
- char *str = new char[len+1];
- cin.getline(str,len+1);
- cout<<"\nInverse string: ";
- for (int i=0; i<len/2; i++) {
- temp=str[len-i-1];
- str[len-i-1]=str[i];
- str[i]=temp;
- }
- cout<<str;
- }
Advertisement
Add Comment
Please, Sign In to add comment