试题与答案

请补充函数fun(),该函数的功能是;交换数组aa中最大和最小两个元素的位置,结果依

题型:填空题

题目:

请补充函数fun(),该函数的功能是;交换数组aa中最大和最小两个元素的位置,结果依然保存在原数组中,其它元素位置不变。注意数组aa中没有相同元素。 例如,输入“33,67,42,58,25,76,85,16,41, 56”,则输出“33,67,42,58,25,76,16,85,41,56”。 注意;部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio. h> #define N 10 void fun(int aa[]) {int i, j, t;int max=0, min=0;for(i=0; i<N; i++){ if( 【1】 ) max=i; if( 【2】 ) min=i;}t=aa [max]; 【3】 ;aa [min] =t; } main() {int i;int aa [N] ={33, 67, 42,58,25, 76, 85,16, 41, 56};clrscr ();printf("\n*** original list ***\n");for(i=0; i<N; i++) printf ("%4d", aa [i] );fun (aa);printf ("\n*** new list ***\n");for(i=0; i<N; i++) printf ("%4d", aa [i]); }

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0401/740537c9cdcdde55331d9df943ec45ac.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
微信公众账号搜索答案