更多"以下函数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