View Code of Problem 114

#include<iostream>
#include<cstring>
using namespace std;
void change(int l,int r,char s[]){
	for(int i=l,j=r;i<j;++i,--j){
		char temp;
		temp=s[i];
		s[i]=s[j];
		s[j]=temp;
	}
}
int main(){
	char a[1000];
    while(gets(a)){
    		int len=strlen(a);
	int i=0,j=0;
	while(j<len){
		while((a[j]>='a'&&a[j]<='z')||(a[j]>='A'&&a[j]<='Z'))
		{
			j++;
		}
		change(i,j-1,a);
		j++;
		i=j;
		if(a[j]=='/n'){
			//change(i,j-1,a);
			break;
		}
		
	}
	cout<<a<<endl;
	}

	return 0;
} 

Double click to view unformatted code.


Back to problem 114