输入几个一串字符串,找出最小的字符串。
作者:互联网
#include<stdio.h>
#include<string.h>
#define N 20
#define M 81
int getstr(char p[][M])
{
char t[M],n=0;
/*printf("enter string a empty string to end\n");
gets(t);*/
while(strcmp(t,""))
{
strcpy(p[n],t);
n++;
gets(t);
}
return n;
}
char *findmin(char(*a)[M],int n)
{
char *q; int i;
q=a[0];
for(i=1;i<n;i++)
if(strcmp(a[i],q)<0)
q=a[i];
return q;
}
int main()
{
char s[N][M],*sp;int n;
n=getstr(s);
sp=findmin(s,n);
puts(sp);
}
标签:char,找出,gets,string,int,一串,字符串,include,define 来源: https://blog.csdn.net/m0_58138734/article/details/117337083