题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-22 13:53:49

[单项选择]以下函数findmax拟实现在数组中查找最大值并作为函数值返回,但程序中有错导致不能实现预定功能,造成错误的原因是
#define MIN -2147483647
int findmax (int X[], int n)
int i, max;
 for(i=0; i<n; i++)
  max=MIN;
  if(max<x[i]) max=x[i];
 
 return max;

A. 定义语句int i, max; 中max未赋初值
B. 赋值语句max=MIN;中,不应给max赋MIN值
C. 语句if(max<x[i]) max=x[i];中判断条件设置错误
D. 赋值语句max=MIN;放错了位置

更多"以下函数findmax拟实现在数组中查找最大值并作为函数值返回,但程序"的相关试题:

[填空题]以下程序中,主函数调用了LineMax函数,实现在N行M列的二维数组中,找出每一行上的最大值。 请填空。 #define N 3 #define M 4 void LineMax(int x[N][M]) { int i,j,P; for(i=0;i<N;i++) { p=0; for(j=1;j<M;j++) if(x[i][p]<x[i][j]) 【9】 ; printf("The max value in line %d is %d/n",i, 【10】 ); } main( ) { int x[N][M]={1,5,7,4,2,6,4,3,8,2,3,1}; 【11】 ; }
[填空题]以下程序中,主函数调用了LineMax函数,实现在N行M列的二维数组中,找出每一行上的最大值。
请填空。
#define N 3
#define M 4
void LineMax(int x[N][M])
int i,j,P;
for(i=0;i<N;i++)
p=0;
for(j=1;j<M;j++)
if(x[i][p]<x[i][j]) 【9】
printf("The max value in line %d is %d/n",i, 【10】 );

main( )
int x[N][M]=1,5,7,4,2,6,4,3,8,2,3,1;
【11】

[填空题]以下和程序中,主函数调用了lineMax函数,实现在N行M列的二维数组中,找出每一行上的最大值,请填空。  # define N 3  # define M 4  void lineMax(int x[N][M])  int i,j,p;   for(i=0;i<N;i+ +)   p=0;    for(j=1;j<M;j+ +)    if(x [i][p]<x[i][j] 【7】 ;  printf("The max value in line is %d/n", 【8】 );        main( )  int x[N][M]=1,5,4,2,6,4,3,8,2,3,1;   【9】
[填空题]以下程序调用findmax( )函数返回数组中的最大值。请填空完成此函数。 #include〈iostream〉 using namespace std; int findmax(int*a,int n) { int +p、*s; for(p=a,s=a;p-a〈n;p++) if(〈u〉 【8】 〈/u〉) *s=*p; return(*S); } int main( ) { int x[5]={12,21,14,16}; cout〈〈findmax(X,5)〈〈end1; return 0; }
[填空题]以下程序调用findmax( )函数返回数组中的最大值。请填空完成此函数。
#include〈iostream〉
using namespace std;
int findmax(int*a,int n)

int +p、*s;
for(p=a,s=a;p-a〈n;p++) if(〈u〉 【8】 〈/u〉)
*s=*p;
return(*S);

int main( )

int x[5]=12,21,14,16;
cout〈〈findmax(X,5)〈〈end1;
return 0;

[单项选择]以下程序调用findmax函数返回数组中的最大值
findmax (inE *a,int n)
int*p,*s;
for(p=a,s=a;p-a<n;p++)
if(______)s=p;
return(*S);

main( )
int x[5]=12,21,13,6,18);
printf("%d/n",findmax(x’5));

在下划线处应填入的是
A. p>s
B. *p>*s
C. a[p]>a[s]
D. p-a>p-s
[填空题]以下程序中select函数的功能是: 在N行M列的二维数组中,选出一个最大值作为函数值返回,并通过形参传回此最大值所在的行下标。请填空。
#define N 3
#define M 3
selectint a[N][M],int *n;
int i,j,row=l,eolum=l;
for(i=0;i<N;i++
for j=0;j<M;j++)
if(a[i][j]>a[row][colum])row=i;colum=j:
*n=______;
return______;

main( )
int a[N][M]=9,11,23.6,1,15,9,17,20, max,nj
max=select(a,&n);
printf("max=%d, line=%d/n",max.n ;

[填空题]以下程序中的select( )函数功能是:在N行M列的二维数组中选出一个最大值作为函数值返回,并通过形参传回此最大值的行下标。请填空完成此程序。
#include<iostream>
#define N 3
#define M 3
using namespace std;
int select(int a[N][M],int *n)

int i,j,row=0,colum=0;
for(i=0;i<N;i++)
for(i=0;j<M;j++)
if(a[i][j]>a[row][colum])

row=i;
colum=j;

*n= 【7】
return 【8】

int main( )

int a[N][M]=9,11,23,6,1,15,9,17,20;
int max,n;
max=select(a,&n);
cout<<"max="<<max<<"line="<<n<<end1;
return 0;

[单项选择]以下程序调用findmax函数返回数组中的最大值
findmax(int*a,int n)
int * p,* s;
for(p=a,s=a;p-a<n;p++)
if(_____)s=p;
return(*s);

main( )
int x[5]=12,21,13,6,18;
printf(“%d/n”,findmax(x,5));

在下划线处应填入的是
A. p>s
B. *p>*s
C. a[p]>a[s]
D. p-a>p-s

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码