题型:问答题 简答题 请编写函数fun,其功能是:找出一维整型数组元素中最大的值所在的下标,并通过形参传回。数组元素中的值已在主函数中赋予。 主函数中x是数组名。n是x中的数据个数,max存放最大值,index存放最大值所在元素的下标。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include<time.h> #include<stdlib.h> #include<stdio.h> void fun(int a[],int n,int*max,int*d) int i; *max=a[0]; *d=0; for(i=0;i<n;i++)/*将最大的 元素放入指针max所指的单元,最大元素的下标放入指针d所指的单元*/ if(*max<a[i]) (*max=a[i];*d=i; void main() int i,x[20],max,index,n=10; scanf((unsigned) time (NULL)); for(i=0;i<=n;i++) x[i]=rand()%50; printf("%4d",x[i]); /*输出一个随机数组*/ printf("\n"); fun(x,n,&max,&index); printf("Max=%5d,Index=%4d\n",max,index); 查看答案
题型:问答题 简答题 Speaker A: Hey, it’s beautiful out today, isn’t it Speaker B: ______.A. Tomorrow will be the same as todayB. Yeah. I wish it would be like this everydayC. At least not as good as I expectedD. Really It’s different from the weather forecast 查看答案