View Code of Problem 52

#include<bits/stdc++.h>
using namespace std;
void trans(string& str,int begin,int len) {
	for(int i=begin,j=i+len-1;i<j;i++,j--) {
		char c;
		c=str[i];
		str[i]=str[j];
		str[j]=c;
	}
}
int main()
{
	string str;
	while(getline(cin,str)) {
		int len = str.length();
		for(int i=0,j=len-1;i<j;i++,j--) {
		char c;
		c=str[i];
		str[i]=str[j];
		str[j]=c;
	}
		cout<<str<<endl;
	}
	return 0;
	
}

Double click to view unformatted code.


Back to problem 52