View Code of Problem 114

#include<string.h>
main(){
	char str[100];
	int len,i,m,n,j,k,t;
	while(gets(str)!=EOF){
		len=strlen(str);
		for(i=0;i<len;){
			for(;!(str[i]>'a'&&str[i]<'z'||str[i]>'A'&&str[i]<'Z');)
				i++;
			m=i;
			for(;str[i]>'a'&&str[i]<'z'||str[i]>'A'&&str[i]<'Z';)
				i++;
			n=i-1;
			for(j=m,k=n;j<(m+n)/2;j++,k--){
				t=str[j];
				str[j]=str[k];
				str[k]=t;
			}
		}
		puts(str);
	}
}
/*
Main.c:2:1: warning: return type defaults to 'int'
 main(){
 ^
Main.c: In function 'main':
Main.c:5:2: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
  while(gets(str)!=EOF){
  ^
Main.c:5:19: error: 'EOF' undeclared (first use in this function)
  while(gets(str)!=EOF){
                   ^
Main.c:5:19: note: each undeclared identifier is reported only once for each function it appears in
Main.c:8:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    for(;!(str[i]>'a'&&str[i]<'z'||str[i]>'A'&&str[i]<'Z');)
                     ^
Main.c:11:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    for(;str[i]>'a'&&str[i]<'z'||str[i]>'A'&&str[i]<'Z';)
                   ^
Main.c:20:3: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
   puts(str);
   ^
*/

Double click to view unformatted code.


Back to problem 114