View Code of Problem 114

//单词逆序;
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
	char a[100];
	while(gets(a)){
		int l=strlen(a);
		int i=0;
		int len=0;
		int t=0;
		int j;
		while(i<l){
			if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z'){
				while(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z'){
					i++;
					len++;
				}
				for(j=len-1;j>=t;j--){
					printf("%c",a[j]);
				}
			}else{
				printf("%c",a[i]);
				len++;
				i++;
			}
			t=i;
		}
		printf("\n");
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 114