#include "stdio.h"
#include <string.h>
int main(int argc,char *argv[]){
char s[101],st[101];
int n,ln,t;
printf("Please enter n(int n>0)...\n");
if(scanf("%d",&n)!=1 || n<1){
printf("Input error, exit...\n");
return 0;
}
ln=100;
while(n--){
scanf("%100s",s);
if((t=strlen(s))<ln){
ln=t;
strcpy(st,s);
}
}
printf("The shortest string is '%s'.\n",st);
return 0;
}
运行们例:
