更多"用指针法求出数组元素中最大者和最小者。 int max,min; "的相关试题:
[填空题]用指针法求出数组元素中最大者和最小者。
int max,min;
void max_min_value(array,n)
int array[],n;
【11】 ;
max=min=*array;
for( 【12】 ;p<array+n;p++)
if(*p>max) max=*p;
else if(*p<min)min=*p;
main( )
int i,number[20],*p;
p=number;
printf("输入20个数据:/n");
for(i=0;i<20;i++,p++) scanf("%d",p);
【13】 ;
max_min_value(p,10);
printf("max=%-10dmin=%d/n",max,rain);
[填空题]若输入12、3、2、5、7,则以下程序的运行结果为 【7】 。
int max,min;
void max_min_value( );
main( )
int i,number[5];
printf("输入5个整数;/n");
for(i=0;i<5;i++) scanf("%d",&number[i]);
max min value(number,5);
printf("max=%d,min=%d/n",max,min);
getch( ); void max_min_value(array,n)
int array[],n;
int*p;
max=min=*array;
for(p=array+1;p<array+n;p++)
if(*p>max)max=*p;
else if(*p<min)min=*p;
[填空题]设int max(int,int)表示计算两个整数中的最大值,则执行语句“cout<<max(max(2,3),max(7,8));”的输出结果是()。
[填空题]将8个数输入数组中,找出其中最大数和最小数并输出。
main( )
int i,max,min,a[8];
for(i=0;i<8;i++)
scanf("%d",&a[i]);
max=a[0];
min=a[0];
for(i=1;i<8;i++)
if(a[i]>max)
max=______;
if(a[i]<min)
______;
printf("max=%d,min=%d/n",______);
[简答题][函数2.1说明]
函数void find(int *a, int n, int * max, int * min)的功能是在长度为n的整型数组a中,查找最大元素和最小元素的下标。main( )中给出了调用find函数的一个实例。
[函数2.1]
#include<stdio.h>
void find(int *a, int n,int *max,int * min)
{ int i;
*max =* min=0;
for(i=1;i<n;i+ +)
if(a[i]>a[* max]) (1) ;
else if(a[i]<a[*min]) (2) ;
return;
main( )
{ int a[]={4,6,8,9,0,6},max,min;
find(a,6, (3) );
printf("%5d%5d/n", max,min);
}
[函数2.2说明]
以下程序用来对从键盘上输入的两个字符串进行比较,然后输出两个字符串前端的公共部分。例如:输入的两个字符串分别是abcdefg和abceef,则输出为abc。
[函数2.2]
#include <stdio.h>
main( )
{ char str1[100],str2[100],str[100],c;
int i=0,s;
printf("/nInput string 1:");gets(str1);
printf("/nInput string 2:");gets(str2);
while(( (4) )&&(str1[i]!=’/0’)&&(str2[i]!=’/0’)){
(5) ;
i++;
}
printf("%s/n",str);
}
[简答题][函数2.1说明]
函数void find(int *a, int n, int * max, int * min)的功能是在长度为n的整型数组a中,查找最大元素和最小元素的下标。main( )中给出了调用find函数的一个实例。
[函数2.1]
#include<stdio.h>
void find(int *a, int n,int *max,int * min)
int i;
*max =* min=0;
for(i=1;i<n;i+ +)
if(a[i]>a[* max]) (1) ;
else if(a[i]<a[*min]) (2) ;
return;
main( )
int a[]=4,6,8,9,0,6,max,min;
find(a,6, (3) );
printf("%5d%5d/n", max,min);[函数2.2说明]
以下程序用来对从键盘上输入的两个字符串进行比较,然后输出两个字符串前端的公共部分。例如:输入的两个字符串分别是abcdefg和abceef,则输出为abc。
[函数2.2]
#include <stdio.h>
main( )
char str1[100],str2[100],str[100],c;
int i=0,s;
printf("/nInput string 1:");gets(str1);
printf("/nInput string 2:");gets(str2);
while(( (4) )&&(str1[i]!=’/0’)&&(str2[i]!=’/0’))
(5) ;
i++;
printf("%s/n",str);
[单项选择]下列程序的输出结果是
# include < iostream.h>
int min( int a,int b)
if(a < b)return a;
else return b;
return 0
void main ( )
cout << min(1,min(2,3)) << endl;
A. 0
B. 1
C. 2
D. 3
[单项选择]下列程序的输出结果是
#include<iostream. h>
int min(int a, int b)
if(a<b) retum a;
else return b;
return 0;
void main( )
cout < < min(1,min(2,3) ) < < endl;
A) 0 B) 1 C) 2 D) 3
[单项选择]下列程序的输出结果是
#include<iostream.h>
int min(int a,int b)
if(a<b) return a;
else return b;
return0;
void main( )
cout<<min (1,min (2,3))<<end1;
A. 0
B. 1
C. 2
D. 3
[简答题]编写函数int fun(int lim, int aa[MAX]),该函数的功能是求出小于或等于lim的所有素数并放在aa数组中,该函数返回所求出的素数的个数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#define MAX 100
int fun(int lim, int se[MAX])
main( )
int limit,i,sum;
int aa[MAX];
clrscr( );
printf("输入一个整数");
scanf("%d",&limit);
sum=fun(limit,aa);
for(i=0;i<sum;i++)
if(i%10==0&&i!=0) /*每行输出10个数*/
printf("/n");
printf("%5d ",aa[i]);
[填空题]下列程序的输出结果为 【10】 。
#inelude<iostream. h>
int &max(int &x, int &y)
return (x>y x: y);
void main( )
int n=3, m=12;
max(m, n)++
cout<<"m="<<m<<", n= "<<n<<end1;
[填空题]下面程序的输出结果是 【15】 。
#define MAX 3
int a[MAX];
main( )
{fun1( );{un2(A) ;printf("/n");}
funl( )
{ int k,t=0;
for(k=0;k<MAX;k++,t++)a[k]=t+t;
}
fun2(int b[])
{ int k;
for(k=0;k<MAX;k++)printf("%d",*(b+k));
}
[填空题]下面程序的输出结果是 【15】 。
#define MAX 3
int a[MAX];
main( )
fun1( );un2(A) ;printf("/n");
funl( )
int k,t=0;
for(k=0;k<MAX;k++,t++)a[k]=t+t;
fun2(int b[])
int k;
for(k=0;k<MAX;k++)printf("%d",*(b+k));
[填空题]下面程序的输出结果是 【7】 。
#define MAX 3
int a[MAX];
main ( )
fun1( );fun2(a);printf("/n");
fun1( )
int k,t=0;
for (k=0;k<MAX;k++,t++) a[k]=t+t;fun2(int b[])
int k;
for (k=0;k<MAX;k++) printf("%d",*(b+k));
[单项选择]Max Weber was one of the most important German intellectuals of his day. He believed that sociological explanations must derive from an understanding of why people choose the actions they do. This belief differed sharply from Durkheim’s view that society and individuals should be studied at different levels. Weber acknowledged that there are social facts that must be analyzed using scientific methods, but he argued that social facts are the total result of individual actions.
The stress on individual action led Weber to look beyond objective behavior and to focus on people’s subjective beliefs, attitudes, values, and motives. According to Weber, sociologists must interpret, not just observe. They must try to see actions from the point of view of the actor. This approach he called verstehen, which in German means emphatic understanding. Weber stressed that verstehen could be systematic. It did not reduce sociological knowledge simply to matter of opinion. But explanations, in his v