while實現求最高分—c語言練習(12)

/例【4-8】從一批以負數結束的成績中求出最高分,用while實現/

循環前先讀入一個數據,假定最大值

#include<stdio.h>
int main(void)
{

    int score,max;
    printf("Enter marks:");
    scanf("%d",&score);
    max=score;
    while(score>=0)
    {
        if(max<score)
            max=score;
        scanf("%d",&score);
    }
    printf("Max=%d",max);
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章