//复杂版且不完善,只判断了前三个字符是否相等
#include<stdio.h>
#include<string.h>
int main(){
char max[100]={'\0'},min[100]={'\0'},x[100];
int b,c,a,i;
while(1){
a=0;b=0;c=0;
printf("Enter word:");
gets(x);
if(x[a]==max[b]) {
a++;b++;
if(x[a]>max[b]) {strcpy(max,x);}
if(x[a]<max[b]) {a=0;b=0;}
if(x[a]==max[b]) {
a++;b++;
if(x[a]>max[b]) {strcpy(max,x);}
if(x[a]<max[b]) {a=0;b=0;}
if(x[a]==max[b]) {
a++;b++;
if(x[a]>max[b]) {strcpy(max,x);}
if(x[a]<max[b]) {a=0;b=0;}}}
}
if(max[b]=="\0") {strcpy(max,x);}
if(x[a]>max[b]) {strcpy(max,x);}
a=0;
if(x[a]==min[c]) {
a++;c++;
if(x[a]<min[c]) {strcpy(min,x);}
if(x[a]>min[c]) {a=0;c=0;}
if(x[a]==min[c]) {
a++;c++;
if(x[a]<min[c]) {strcpy(min,x);}
if(x[a]>min[c]) {a=0;c=0;}
if(x[a]==min[c]) {
a++;c++;
if(x[a]<min[c]) {strcpy(min,x);}
if(x[a]>min[c]) {a=0;c=0;}}}
}
if(min[c]=='\0'){strcpy(min,x);}
if(x[a]<min[c]) {strcpy(min,x);}
for(i=0;x[i]!='\0';i++)
;
if((i)==4) break;
}
printf("Smallest word:%s\n",min);
printf("Largest word:%s",max);
return 0;
}
//简化版
/*#include<stdio.h>
#include<string.h>
int main(){
char max[100]={'\0'},min[100]={'\0'},x[100];
int i,a,b,c;
while(1){
a=0;b=0;
printf("Enter word:");
gets(x);
if(max[a]=='\0') strcpy(max,x);
if(min[b]=='\0') strcpy(min,x);
i=strcmp(x,max);
if(i>0) strcpy(max,x);
i=strcmp(x,min);
if(i<0) strcpy(min,x);
for(c=0;x[c]!='\0';c++)
;
if(c==4) break;
}
printf("Smallest word:%s\n",min);
printf("Largest word:%s",max);
return 0;
}*/