快乐学习 一个网站喵查铺子(catpuzi.com)全搞定~

下面程序的功能是从键盘输入10个整数,用函数编程实现计算其最大值最小值,并互换它们所在数组中的位置。程序运行结果如下:Input n(n<=10):10↙Input 10 Numbers:1 4 3 0 –2 6 7 2 9 -1 ↙Exchange results:     1     4     3     0     9     6     7     2    -2    -1按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include   void ReadData(int a[], int n); void PrintData(int a[], int n); void  MaxMinExchang(int a[], int n); void Swap(int *x, int *y); int main() {     int  a[10], n;     printf("Input n(n<=10):");     scanf("%d", &n);     printf("Input %d numbers:", n);     ReadData(a, n);      MaxMinExchang(a, n);     printf("Exchange results:");     PrintData(a, n);      return 0; } /* 函数功能:输入数组a的n个元素值 */ void ReadData(int a[], int n)   {     int i;     for (i=0; i<n; i++)      {           scanf("%d", &a[i]);      } } /* 函数功能:输出数组a的n个元素值 */ void PrintData(int a[], int n)   {     int i;     for (i=0; i<n; i++)      {           printf("%5d", a[i]);      }     printf("\n"); } /* 函数功能:将数组a中的最大数与最小数位置互换 */ void  MaxMinExchang(________, int n) {     int  maxValue = a[0], minValue = a[0], maxPos = 0, minPos = 0;     int  i;     for (i=1; i maxValue)         {             maxValue = _______;             maxPos = ____;         }         if (a[i] < minValue)         {             minValue = a[i];             minPos = i;        } }         Swap(________________); } /* 函数功能:两整数值互换 */ void  Swap(int *x, int *y)                 {     int  ________;     temp = *x;                               _________;                          *y = temp;             }

中国大学MOOC答案 数据帝 2024-04-09 扫描二维码

A、第41行: int a[]第49行: a[i]第50行: i第58行: &a[maxPos], &a[minPos]第64行: temp第66行: *x = *y
B、第41行: int a第49行: a[i]第50行: i第58行: a[maxPos], a[minPos]第64行: temp第66行: *x = *y
C、第41行: int a[]第49行: a[0]第50行: 0第58行: &a[maxPos], &a[minPos]第64行: *temp第66行: x = y
D、第41行: int a[]第49行: a[n-1]第50行: n-1第58行: *a[maxPos], *a[minPos]第64行: &temp第66行: x = y
喵查答案:第41行: int a[]第49行: a[i]第50行: i第58行: &a[maxPos], &a[minPos]第64行: temp第66行: *x = *y

喜欢 (0)
关于作者: