问答题

编写一个函数,从传入的num个字符中找出最长的一个字符串,并通过形参指针max传回该串地址(用****作为结束输入的标志)。 注意:部分源程序给出如下. 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include<conio.h> #include<stdio.h> #include<string.h> fun(char (*a) [81], int num, char *max) { } main () { char ss[l0] [81],*ps; int n, i=0; clrscr(); prlntf("输入若干个字符串"); gets(ss[i]); puts(ss[i]); while(!strcmp(ss[i], "****")==0) /*用****作为结束输入的标志*/ { i++; gets(ss[i]); puts(ss[i]); } n=i; ps=fun(ss,n,&ps); print~("\nmax=%s\n",ps); }

【参考答案】

fun(char (*a)[81], int num, char *max) { int i=0; max=a[0]......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)