View Code of Problem 114

#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
	int i,j,n,m,k,x;
	char a[100];
	while(gets(a)!=NULL){
		n=strlen(a);
		for(i=0;i<n;i++){
			while(a[i]==' ')
				i++;
			m=i;
			while(isalpha(a[i]))
				i++;
			k=i-1;
			for(j=m;j<=(k+m)/2;j++){  //逆序 
    	   		char t=a[j];
    			a[j]=a[m+k-j];
    			a[m+k-j]=t;
			}
		}
		puts(a);
	} 
	return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:7:14: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  while(gets(a)!=NULL){
              ^
In file included from Main.cc:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
Main.cc:7:14: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
  while(gets(a)!=NULL){
              ^
In file included from Main.cc:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
Main.cc:13:10: error: 'isalpha' was not declared in this scope
    while(isalpha(a[i]))
          ^~~~~~~
Main.cc:5:16: warning: unused variable 'x' [-Wunused-variable]
  int i,j,n,m,k,x;
                ^
*/

Double click to view unformatted code.


Back to problem 114