举一反三
- 以下程序的功能是:从键盘上输入若干个学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入,请在划线处填空。#include 〈stdio.h〉main(){ float x,max,min; ______①______; //输入第一个数作为 max,min起点 max=x;min=x; while(___②___) { if(x>max) __③__; if( __④___ ) min=x; scanf("%f",&x); } printf("Max=%f\nMin=%f\n",max,min); return 0;}
- 以下程序功能:接收输入的若干名学生成绩,统计并输出最高成绩和最低成绩,当输入负数时结束接收。请完成填空。 #include int main() { float x,max,min; //max存放最大值,min存放最小值 scanf("%f",&x); max=min=x; while( (1 )&&x[=100 )//当成绩不是负数时执行循环体 { if(x]max) max=x; else if(x<min) (2) (3) } printf("%f,%f",max,min); return 0; }
- 下列程序的功能是从键盘上输入若干员工的工资,统计并输出最高工资和最低工资,当输入负数时结束输入。 main() float x,max,min; scanf("%f",&x); ______ while(______) if(x>max)max=x; if(x<min)min=x; ______ printf("\nmax=%f\nmin=%f\n",max,min);
- 以下程序的功能是:从键盘上输入若干个学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入,请填空。(答案中请不要带空格,答案之间用3个空格键间隔) #include[iostream] using namespace std; void main() { float x,max,min; cin>>x; max=x; min=x; while( ) { if ( ) max=x; if( ) min=x; cin>>x; } cout<<"\nmax="<< max <<"\nmin="<< min<<"\n"; }
- *【程序填空】题目:输入10个数,求其中的最大值与最小值。*/ #include "stdio.h" main( ) { int x, max, min,i; scanf("%d",&x); max=x; /***********SPACE***********/ 【?】 i=1; /***********SPACE***********/ while(【?】) { scanf("%d",&x); /***********SPACE***********/ if(x>max) 【?】; if(x
内容
- 0
下面程序的功能是从键盘上输入若干学生的学习成绩,统计并输出最高成绩和最低成绩,当输入为负数时结束输入。 main() { float x,amax,amin; scanf("%f",&x); amax=x; amin=x; while( ① ) { if(x>amax) amax=x; if( ② ) amin=x; scanf("%f",&x); } printf("\namax=%f\namin=%f\n",amax,amin); }
- 1
/*【程序填空】题目:求一批数中的最大值,以-1作终止标记。*/#include"stdio.h"main(){/***********SPACE***********/intx,【?】;/***********SPACE***********/scanf("%d",【?】);max=x;/***********SPACE***********/while(【?】){if(x>max)max=x;/***********SPACE***********/scanf("【?】",&x);}printf("max=%d ",max);}
- 2
#include void main() { int max(flaot x, float y); float a, b; int c; scanf(“%f,%f”, &a, &b); c=max(a, b); printf(“Max is %d”, c);} int max(float x, float y) { float z; z = x > y ? x : y; return z;} 函数max的返回值是什么数据类型( )
- 3
编写函数,求一组数中的最大值、最小值和平均值。其中用全局变量max存放最大值,min存放最小值,函数返回平均值。 #include int max,min; float fun(int a[ ],int n) { } int main() { int x[10],i,m,n; float p; for(i=0;i<10;i++) scanf("%d",&x[i]); p=fun(x,10); printf("max=%d,min=%d,average=%.2f ",max,min,p); return 0; } 输入样例: 2 5 4 8 6 9 1 3 7 0 输出样例: max=9,min=0,average=4.50
- 4
假设输入5,10,以下程序运行的结果是( )。#include stdio.hint max(int a,int b){ if(a=b) return a; else return b;}int min(int a,int b){ if(a=b) return b; else return a;}void f(int a,int b,int(*p)(int,int)){ printf(%d\n,(*p)(a,b));}int main(){ int x,y; scanf(%d,%d,x,y); f(x,y,max); f(x,y,min); return 0;} A: 105 B: 55 C: 510 D: 1010