/*------------------------------------------------------- 功能:从键盘上输入若干个学生的成绩,统计并输出最高成绩和最 低成绩,当输入负数时结束输入。(使用while循环) --------------------------------------------------------*/ #include main() { int x,max,min; printf("please input x:\n"); scanf("%d",&x); max=x; min=x; /**********Program**********/ while(x > 0){ if(x > max){ max = x; } if(x < min){ min = x; } scanf("%d", &x); } /********** End **********/ printf("max=%d,min=%d\n",max,min); }