2025-03-06 22:45:14 +08:00

30 lines
534 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
功能:从键盘上输入若干个学生的成绩,统计并输出最高成绩和最
低成绩当输入负数时结束输入。使用while循环
--------------------------------------------------------*/
#include <stdio.h>
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);
}