目录
题目一“回文”字符串 .................................................................................................................................................................. 3 题目二迭代法求给定多项式的值 .............................................................................................................................................. 7 题目三迭代法求给定方程的根 .................................................................................................................................................. 9 题目四二维数组三角元素操作1 ............................................................................................................................................. 11 题目四二维数组三角元素操作2 ............................................................................................................................................. 15 题目四二维数组三角元素操作3 ............................................................................................................................................ 19 题目五二维数组元素求最值 .................................................................................................................................................... 24 题目六二维数组周边元素1 ..................................................................................................................................................... 26 题目六二维数组周边元素2 .................................................................................................................................................... 29 题目七二维数组转一维数组1 ................................................................................................................................................ 33 题目七二维数组转一维数组2 ................................................................................................................................................ 36 题目七二维数组转一维数组3 ................................................................................................................................................ 39 题目七二维数组转一维数组4 ................................................................................................................................................ 43 题目八结构体数组排序1 ........................................................................................................................................................ 46 题目八结构体数组排序2 ........................................................................................................................................................ 49 题目八结构体数组排序3 ........................................................................................................................................................ 52 题目八结构体数组排序4 ........................................................................................................................................................ 56 题目九结构体数组求最值1 .................................................................................................................................................... 60 题目九结构体数组求最值2 .................................................................................................................................................... 63 题目九结构体数组求最值3 .................................................................................................................................................... 66 题目九结构体数组求最值4 .................................................................................................................................................... 66 题目十结构体数组筛选 ............................................................................................................................................................ 69 题目十一结构体数组字符串比较 ............................................................................................................................................ 73 题目十二矩阵操作1 ................................................................................................................................................................ 76 题目十二矩阵操作2 ................................................................................................................................................................ 78 题目十三类似素数判断1 ........................................................................................................................................................ 82 题目十三类似素数判断2 ........................................................................................................................................................ 83 题目十四累加累乘求和1 ........................................................................................................................................................ 85 题目十四累加累乘求和2 ........................................................................................................................................................ 87 题目十四累加累乘求和3 ........................................................................................................................................................ 88 题目十四累加累乘求和4 ........................................................................................................................................................ 90 题目十四累加累乘求和5 ........................................................................................................................................................ 92 题目十四累加累乘求和6 ........................................................................................................................................................ 95 题目十四累加累乘求和7 ........................................................................................................................................................ 97 题目十四累加累乘求和8 ........................................................................................................................................................ 99 题目十四累加累乘求和9 ...................................................................................................................................................... 101 题目十四累加累乘求和10 .................................................................................................................................................... 103
题目十四累加累乘求和11 .................................................................................................................................................... 105 题目十四累加累乘求和12 .................................................................................................................................................... 107 题目十四累加累乘求和13 .................................................................................................................................................... 109 题目十四累加累乘求和14 .................................................................................................................................................... 111 题目十四累加累乘求和15 .................................................................................................................................................... 114 题目十四累加累乘求和16 .................................................................................................................................................... 116 题目十五链表1 ...................................................................................................................................................................... 119 题目十五链表2 ...................................................................................................................................................................... 123 题目十六删除整数位某数位 .................................................................................................................................................. 126 题目十七删除字符串中指定字符1 ...................................................................................................................................... 129 题目十七删除字符串中指定字符2 ...................................................................................................................................... 131 题目十七删除字符串中指定字符3 ...................................................................................................................................... 133 题目十七删除字符串中指定字符4 ...................................................................................................................................... 135 题目十七删除字符串中指定字符5 ...................................................................................................................................... 137 题目十七删除字符串中指定字符6 ...................................................................................................................................... 139 题目十七删除字符串中指定字符7 ...................................................................................................................................... 140 题目十七删除字符串中指定字符8 ...................................................................................................................................... 142 题目十七删除字符串中指定字符9 ...................................................................................................................................... 144 题目十七删除字符串中指定字符10 .................................................................................................................................... 146 题目十七删除字符串中指定字符11 .................................................................................................................................... 148 题目十七删除字符串中指定字符12 .................................................................................................................................... 150 题目十七删除字符串中指定字符13 .................................................................................................................................... 153 题目十七删除字符串中指定字符14 .................................................................................................................................... 155 题目十七删除字符串中指定字符15 .................................................................................................................................... 158 题目十七删除字符串中指定字符16 .................................................................................................................................... 160 题目十七删除字符串中指定字符17 .................................................................................................................................... 163 题目十七删除字符串中指定字符18 .................................................................................................................................... 166 题目十八数字字符串转整数1 .............................................................................................................................................. 168 题目十八数字字符串转整数2 .............................................................................................................................................. 170 题目十九素数判定1 .............................................................................................................................................................. 172 题目十九素数判定2 .............................................................................................................................................................. 174 题目十九素数判定3 .............................................................................................................................................................. 176 题目二十统计问题 .................................................................................................................................................................. 180 题目二十一小数位操作 .......................................................................................................................................................... 183 题目二十二一维数组或字符串排序1 .................................................................................................................................. 185 题目二十二一维数组或字符串排序2 .................................................................................................................................. 187 题目二十二一维数组元素的筛选1 ...................................................................................................................................... 190 题目二十二一维数组元素的筛选2 ...................................................................................................................................... 192
题目二十二一维数组元素的筛选3 ...................................................................................................................................... 194 题目二十二一维数组元素的筛选4 ...................................................................................................................................... 196 题目二十二一维数组元素的筛选5 ...................................................................................................................................... 198 题目二十二一维数组元素的筛选6 ...................................................................................................................................... 201 题目二十二一维数组元素的筛选7 ...................................................................................................................................... 203 题目二十二一维数组元素的筛选8 ...................................................................................................................................... 206 题目二十二一维数组元素的筛选9 ...................................................................................................................................... 208 题目二十三一维数组元素筛选 .............................................................................................................................................. 210 题目二十五一维数组最值求解1 .......................................................................................................................................... 212 题目二十五一维数组最值求解2 .......................................................................................................................................... 215 题目二十五一维数组最值求解3 .......................................................................................................................................... 217 题目二十六移动问题1 .......................................................................................................................................................... 219 题目二十六移动问题2 .......................................................................................................................................................... 221 题目二十七整数合并1 .......................................................................................................................................................... 224 题目二十七整数合并2 .......................................................................................................................................................... 225 题目二十七整数合并3 .......................................................................................................................................................... 226 题目二十七整数合并4 .......................................................................................................................................................... 228 题目二十七整数合并5 .......................................................................................................................................................... 229 题目二十七整数合并6 .......................................................................................................................................................... 230 题目二十七整数合并7 .......................................................................................................................................................... 231 题目二十七整数合并8 .......................................................................................................................................................... 233 题目二十八字符串长度比较1 .............................................................................................................................................. 234 题目二十八字符串长度比较2 .............................................................................................................................................. 236 题目二十九字符串的逆置 ...................................................................................................................................................... 239 题目三十字符串计数 .............................................................................................................................................................. 242 题目三十一字符串连接1 ...................................................................................................................................................... 244 题目三十一字符串连接2 ...................................................................................................................................................... 246 题目三十一字符串连接3 ...................................................................................................................................................... 249 题目三十二字符串中指定字符查找 ...................................................................................................................................... 250 题目三十三字母大小的判断及转换 ...................................................................................................................................... 252
题目一“回文”字符串
3. 请编写函数fun,该函数的功能是:判断字符串是否为回文,若是,则函数返回1,
主函数中输出\"YES\",否则返回0,主函数中输出\"NO\"。回文是指顺读和倒读都一样的字符串。
例如,字符串LEVEL是回文,而字符串123312就不是回文。
#include #define N 80 int fun(char *str) { int i,n=0,fg=1; char *p=str; while (*p) { n++; p++; } /*将指针p置位到字符串末尾,并统计字符数*/ for(i=0;i else /*不同,直接跳出循环*/ { fg=0; break; } return fg; } main() { char s[N]; FILE *out; char *test[]={\"1234321\ int i; printf(\"Enter a string : \"); gets(s); printf(\"\\n\\n\"); puts(s); if(fun(s)) printf(\"YES\\n\"); else printf(\"NO\\n\"); /************************************/ out=fopen(\"out.dat\ for(i=0;i<4;i++) if(fun(test[i])) fprintf(out,\"YES\\n\"); else fprintf(out,\"NO\\n\"); fclose(out); /************************************/ } 题目二迭代法求给定多项式的值 3.编写函数fun,其功能是:根据以下公式求π的值(要求精度0.0005,即某项小于0.0005时停止迭代)。 112123123412…n1……2335357357935…2n1 程序运行后,若输入精度 0.0005,则程序应输出为3.14…。 #include #include double fun ( double eps) { double s=1.0,s1=1.0; int n=1; while(s1>=eps) /*当某项大于精度要求时,继续求下一项*/ {s1=s1*n/(2*n+1); /*求多项式的每一项*/ s=s+s1; /*求和*/ n++; } return 2*s; } main( ) { double x;void NONO (); printf(\"Input eps:\") ; scanf(\"%lf\ NONO(); } 题目三迭代法求给定方程的根 3. 编写函数fun,其功能是:利用下面的简单迭代方法求方程cos(x)-x=0的一个实根。 xn1cos(xn) 迭代步骤如下: (1)取x1初值为0.0; (2)x0=x1,将x1的值赋给x0; (3)x1=cos(x0),求出一个新的x1; (4)若x0-x1的绝对值小于0.000001,执行步聚(5),否则执行步聚(2); (5)所求x1就是方程cos(x)-x=0的一个实根,作为函数值返回。 程序将输出结果Root=0.739086。 #include #include double fun() { double x0,x1; x1=0.0; do { x0=x1; x1=cos(x0); }while(fabs(x0-x1)>=1e-6); return x1; } main() { void NONO ( ); printf(\"Root =%f\\n\ NONO(); } 题目四二维数组三角元素操作1 3. 程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N],int n),该函数的功能是:使数组左下半三角元素中的值乘以n。例如,若n的值为3,a数组中的值为: 则返回主程序后a数组中的值应为: 1a24935786 3612 99157818 #include #include #include #define N 5 void fun(int a[ ][N], int n) { int i,j; for(i=0;i a[i][j]=a[i][j]*n; } main() { int a[N][N],n, i,j; FILE *out; printf(\"***** The array *****\\n\"); for(i=0; i for(j=0; j a[i][j]=rand()%10; printf(\"%4d\ } printf(\"\\n\"); } n=rand()%4; printf(\"n=%4d\\n\ fun(a, n); printf(\"*****THE RESULT*****\\n\"); for(i=0; i for (j=0; j printf(\"\\n\"); } /******************************/ out=fopen(\"out.dat\ for(i=0;i fun(a,9); for(i=0;i for(j=0;j fprintf(out,\"\\n\"); } fclose(out); /******************************/ } 题目四二维数组三角元素操作2 3. 下列程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N]),该函数的功能是:将数组左下半三角元素中的值全部置成0。例如a数组中的值为: 1 9 7 2 3 8 4 则返回主程序后a数组中的值应为: 0 0 0 #include #include #include #define N 5 void fun (int a[][N]) 5 6 9 7 0 8 0 0 { int i,j; for(i=0;i a[i][j]=0; /*将数组左下半三角元素中的值全部置成0*/ } void main() { FILE *wf; int a[N][N],i,j; int b[N][N]={1,9,7,2,4,2,3,8,1,2,4,5,6,7,5,4,0,6,8,0,2,7,1,6,4}; system(\"CLS\"); printf(\"*****The array*****\\n\"); for(i=0;i printf(\"%4d\ } printf(\"\\n\"); } fun(a); printf(\"THE RESULT\\n\"); for(i=0;i printf(\"\\n\"); } /******************************/ wf=fopen(\"out.dat\ fun(b); for(i=0;i fprintf(wf,\"\\n\"); } fclose(wf); /*****************************/ } 题目四二维数组三角元素操作3 3. 下列程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[ ][N],int m),该函数的功能是使数组右上半三角元素中的值乘以m。 例如,若m的值为2,a数组中的值为: 197 则返回主程序后a数组中的值应为: #include #include #include #include #define N 5 void fun(int a[][N], int m) { 2182645a2 4141612 3856 int i,j; for(j=0;j a[i][j]=a[i][j]*m; /*右上半三角元素中的值乘以m*/ } main() { int a[N][N],m, i, j; FILE *out; printf(\"*****The array*****\\n\"); for(i=0;i printf(\"%4d\ } printf(\"\\n\"); } m=rand()%4; printf(\"m=%4d\\n\ fun(a,m); printf(\"THE RESULT\\n\"); for(i=0;i printf(\"\\n\"); } /******************************/ out=fopen(\"out.dat\ for(i=0;i fun(a,8); for(i=0;i fprintf(out,\"\\n\"); } fclose(out); /******************************/ } 题目五二维数组元素求最值 3. 请编写函数fun,其功能是:找出2×M整型二维数组中最大元素的值,并将此值返回调用函数。 #include #define M 4 int fun (int a[][M]) { int i,j,max=a[0][0]; for(i=0;i<2;i++) for(j=0;j return max; } main( ) { int arr[2][M]={5,8,3,45,76,-4,12,82} ;void NONO (); printf(\"max =%d\\n\ NONO( ) ; } void NONO () {/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。FILE *wf ; int arr[][M]={5,8,3,90,76,-4,12,82} ; wf = fopen(\"out.dat\ fprintf(wf, \"max=%d\\n\ fclose(wf) ; */ } 题目六二维数组周边元素1 3.下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun,函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如,若a 数组中的值为: 0 1 2 7 9 1 9 7 4 5 2 3 8 3 1 4 5 6 8 2 5 9 1 4 1 则返回主程序后s的值应为3.375。 #include #include #include #define N 5 double fun (int w[][N]) { int i,j,k=0; double av=0.0; for(i=0;i {av=av+w[i][j]; /*将周边元素求和*/ k++; } return av/k; /*求周边元素的平均值*/ } void main() { FILE *wf; int a[N][N]={0,1,2,7,9,1,9,7,4,5,2,3,8,3,1,4,5,6,8,2,5,9,1,4,1}; int i, j; double s; system(\"CLS\"); printf(\"*****The array*****\\n \"); for (i=0; i printf(\"\\n \"); } s=fun(a); printf(\"*****THE RESULT*****\\n \"); printf(\"The sum is : %lf\\n \ /******************************/ wf=fopen(\"out.dat\ fprintf (wf,\"%lf\ fclose(wf); /*****************************/ } 题目六二维数组周边元素2 3. 请编写函数fun,该函数的功能是:求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。 例如,若二维数组中的值为: 1 3 5 7 9 2 9 9 9 4 6 9 9 9 8 1 3 5 7 0 则函数值为61。 #include #include #include #define M 4 #define N 5 int fun( int a [M][N]) { int i,j,sum=0; for(i=0;i sum=sum+a[i][j]; /*将周边元素相加*/ return sum; } void main() { FILE *wf; int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},{6,9,9,9,8},{1,3,5,7,0}}; int i, j, y; system(\"CLS\"); printf (\"The original data is :\\n \"); for(i=0; i printf(\"\\n \"); } y=fun(aa); printf(\"\\nThe sun: %d\\n \ printf(\"\\n \"); /******************************/ wf=fopen(\"out.dat\ fprintf (wf,\"%d\ fclose(wf); /*****************************/ } 题目七二维数组转一维数组1 3.请编写函数fun,该函数的功能是:将M行N列的二维数组中的数据,按列的顺序依次放到一维数组中。一维数 组中数据的个数存放在形参n所指的存储单元中。 例如,若二维数组中的数据为 33 33 33 33 44 44 44 44 55 55 55 55 则一维数组中的内容应是: 33 44 55 33 44 55 33 44 55 33 44 55 #include void fun(int (*s)[10],int *b,int *n,int mm,int nn) { int i,j; for(j=0;j b[*n]=*(*(s+i)+j); *n=*n+1; /*通过指针返回元素个数*/ } } void main() { int w[10][10]={{33,33,33,33},{44,44,44,44},{55,55,55,55}}, i, j; int a[100]={0},n=0 ; FILE *out; printf(\"The matrix:\\n\"); for (i=0; i<3; i++) {for (j=0;j<4;j++) printf(\"%3d\ printf(\"\\n\"); } fun(w,a,&n,3,4); /******************************/ out=fopen(\"out.dat\ printf(\"The A array:\\n\"); for(i=0; i fprintf(out,\"%d \ } printf(\"\\n\\n\"); fclose(out); /******************************/ } 题目七二维数组转一维数组2 3. 请编写函数fun,该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。 例如,若二维数组中的数据为 W W W W S S S S H H H H 则字符串中的内容应是:WSHWSHWSHWSH。 #include #define M 3 #define N 4 void fun(char (*s)[N],char *b) { int i,j,k=0; for(i=0;i b[k]='\\0'; } void main() { FILE *wf; char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}}; int i,j; printf(\"The matrix:\\n\"); for(i=0;i printf(\"\\n\"); } fun(w,a); printf(\"The A string:\\n\"); puts(a); printf(\"\\n\\n\"); /******************************/ wf=fopen(\"out.dat\ fprintf(wf,\"%s\ fclose(wf); /*****************************/ } 题目七二维数组转一维数组3 1. 请编一个函数void fun(int tt[M][N], int pp[N]), tt指向一个M行N列的二维数组,求出二维数组每列中最大元素,并依次放入pp所指的一维数组中。二维数组中的数已在主函数中给出。 #include #include #include #define M 3 #define N 4 void fun(int tt[M][N],int pp[N]) { int i,j,max; for(j=0;j max=tt[0][j]; /*假设各列中的第一个元素最大*/ for(i=0;i max=tt[i][j]; pp[j]=max; /*将各列的最大值依次放入pp数组中*/ } } main( ) { void NONO( ); int t[M][N]={{68, 32, 54, 12},{14, 24, 88, 58},{42, 22, 44, 56}}; int p [ N ], i, j, k; printf ( \"The original data is : \\n\" ); for( i=0; i printf(\"\\n\"); } fun ( t, p ); printf( \"\\nThe result is:\\n\" ); for ( k = 0; k < N; k++ ) printf ( \" %4d \ printf(\"\\n\"); NONO( ); } void NONO( ) {/* 请在此函数内打开文件,输入测试数据,调用 fun 函数, 输出数据,关闭文件。 */ int i, j, k, m, t[M][N], p[N] ; FILE *rf, *wf ; rf = fopen(\"in.dat\ wf = fopen(\"out.dat\ for(m = 0 ; m < 10 ; m++) { for( i=0; i } fun ( t, p ) ; for ( k = 0; k < N; k++ ) fprintf (wf, \" %4d \ fprintf(wf, \"\\n\") ; } fclose(rf) ; fclose(wf) ; } 题目七二维数组转一维数组4 3.请编写函数fun,该函数的功能是:将M行N列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参n所指的存储单元中。 例如,若二维数组中的数据为: 33 33 33 33 44 44 44 44 55 55 55 55 则一维数组中的内容应该是:33 33 33 33 44 44 44 44 55 55 55 55。 #include void fun (int (*s)[10], int *b, int *n, int mm, int nn) { int i,j,k=0; for(i=0;i *n=k; /*通过指针返回元素个数*/ }void main() { FILE *wf; int w[10][10]={{33,33,33,33},{44,44,44,44},{55,55,55,55}}, i, j; int a[100]={0},n=0 ; printf(\"The matrix:\\n\"); for (i=0; i<3; i++) {for (j=0;j<4;j++) printf(\"%3d\ printf(\"\\n\"); } fun(w,a,&n,3,4); printf(\"The A array:\\n\"); for(i=0; i printf(\"\\n\\n\"); /******************************/ wf=fopen(\"out.dat\ for(i=0; i fclose(wf); /*****************************/ } 题目八结构体数组排序1 1. 学生的记录由学号和成绩组成,N名学生的数 据已放入主函数中的结构体数组s中,请编写函数fun,其功能是:按分数降序排列学生的记录,高分在前,低分在后。 #include #define N 16 typedef struct { char num[10]; int s; } STREC; void fun( STREC a[] ) { int i,j; STREC t; for(i=1;i } main() { STREC s[N]={{\"GA005\ {\"GA001\ {\"GA015\ {\"GA011\ int i;FILE *out ; fun( s ); printf(\"The data after sorted :\\n\"); for(i=0;i printf(\"%s %4d \ } printf(\"\\n\"); out = fopen(\"out.dat\ for(i=0;i fprintf(out, \"%4d \ } fprintf(out,\"\\n\"); fclose(out) ; } 题目八结构体数组排序2 3.学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun ,其功能是:把低于平均分的学生数据放入b所指的数组中,低于平均分的学生人数通过形参n传回,平均分通过函数值返回。 #include #define N 8 typedef struct { char num[10]; double s; } STREC; double fun( STREC *a, STREC *b, int *n ) { int i,j=0; double av=0.0; for(i=0;i av=av/N; /*求平均值*/ for(i=0;i return av; /*返回平均值*/ } main() { STREC s[N]={{\"GA05\ {\"GA01\ STREC h[N],t;FILE *out ; int i,j,n; double ave; ave=fun( s,h,&n ); printf(\"The %d student data which is lower than %7.3f:\\n\ for(i=0;i printf(\"\\n\"); out = fopen(\"out.dat\ fprintf(out, \"%d\\n%7.3f\\n\ for(i=0;i for(i=0;i fclose(out); } 题目八结构体数组排序3 3. 学生的记录由学号和成绩组成,N名学生的数据已放入主函数中的结构体数组s中。请编写函数fun,其功能是:把指定分数范围内的学生数据放在b所指的数组中,分数范围内的学生人数由函数值返回。 例如,输入的分数是60、69,则应当把分数在60~69的学生数据输出,包含60分和69分的学生数据。主函数中把60放在low中,把69放在heigh中。 #include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC *a,STREC *b,int l, int h ) { int i,j=0; for(i=0;i /*将分数高于l,低于h的学生记录存入结构体数组b中*/ b[j++]=a[i]; return j; /*返回分数范围内的学生人数*/ } main() { STREC s[N]={{\"GA005\ {\"GA001\ {\"GA015\ {\"GA011\ STREC h[N],tt;FILE *out ; int i,j,n,low,heigh,t; printf(\"Enter 2 integer number low & heigh : \"); scanf(\"%d%d\ if ( heigh< low ){ t=heigh;heigh=low;low=t; } n=fun( s,h,low,heigh ); printf(\"The student's data between %d--%d :\\n\ for(i=0;i printf(\"\\n\"); out = fopen(\"out.dat\ n=fun( s,h,80,98 ); fprintf(out,\"%d\\n\ for(i=0;i for(i=0;i fprintf(out,\"\\n\"); fclose(out); } 题目八结构体数组排序4 1. 请编写函数fun,该函数的功能是:统计各年龄段的人数。N个年龄通过调用随机函数获得,并放入主函数的age数组中。要求函数把0~9岁年龄段的人数放在d[0]中,把10~19岁年龄段的人数放在d[1]中,把20~29岁年龄段的人数放在d[2]中,依此类推,把100岁(含100岁)以上年龄的人数都放在d[10]中。结果在主函数中输出。 #include # define N 50 # define M 11 void fun(int *a, int *b) { int i,j; for(j=0;j for(i=0;i b[10]++; /*如果年龄大于等于100,b[10]自增1*/ else b[a[i]/10]++; /*如果年龄小于100,则将其分别统计到b[a[i]/10]中*/ } double rnd() { static t=29,c=217,m=1024,r=0; r=(r*t+c)%m; return((double)r/m); }double rnd() { static t=29,c=217,m=1024,r=0; r=(r*t+c)%m; return((double)r/m); } void main() { FILE *wf; int age[N], i,d[M]; int b[N]={32,45,15,12,86,49,97,3,44,52,17,95,63}; for(i=0; i printf(\"The original data :\\n\"); for(i=0; i printf(\"\\n\\n\"); fun(age,d); for(i=0; i<10; i++) printf(\"%4d---%4d :%4d\\n\ printf(\"Over 100 : %4d\\n\ /******************************/ wf=fopen(\"out.dat\ fun(b,d); for(i=0; i<10; i++) fprintf(wf,\"%4d---%4d :%4d\\n\ fprintf(wf,\"Over 100 : %4d\ fclose(wf); /*****************************/ } 题目九结构体数组求最值1 3.学生的记录由学号和成绩组成,N名学生的数据已放入主函数中的结构体数组s中,请编写函数fun,其功能是:把分数最高的学生数据放在b所指的数组中。注意:分数最高的学生可能不止一个,函数返回分数最高的学生的人数 #include #define N 16 typedef struct { char num[10]; int s; } STREC; int fun( STREC *a, STREC *b ) { int i,j=0,max=a[0].s; /*找出最大值*/