• 2022-06-07
    从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入。请在下列程序中填空。 #include int main() { float x,max,min; printf("please input scores:"); scanf("%f",&x); max=min=x; while(___1___) { if(___2__)max=x; if(___3__)min=x; scanf("%f",&x); } printf(" max=%f min=%f ",max,min); getchar(); }
  • 第一空: x>=0 x>max x=0 maxx;x>=0 x>max min>x;x>=0 max

    举一反三

    内容

    • 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