#29323: c解答


jeff123 (NightSky)

學校 : 高雄私立正義高級中學
編號 : 180351
來源 : [118.171.6.211]
最後登入時間 :
2024-05-16 21:58:32
b964. 1. 成績指標 -- 2016年3月apcs | From: [1.173.144.253] | 發表日期 : 2022-02-15 20:15

#include <stdio.h>

#include <stdlib.h>

 

int main()

{

    int a=0,d=0,s[20],f=0,t=0;

    for(d=1;d<=20;d++)

        s[d]=0;

    scanf("%d",&a);

    for(d=1;d<=a;d++)

        scanf("%d",&s[d]);

    for(f=1;f<=a;f++)

    {

        for(d=1;d<=a-1;d++)

        {

           if( s[d]>=s[d+1])

           {

             t=s[d];

             s[d]=s[d+1];

             s[d+1]=t;

           }

        }

    }

    for(d=1;d<=a;d++)

        printf("%d ",s[d]);

    t=-1;

    for(d=1;d<=a;d++)

    {

        if(s[d]<=59 && s[d]>=t)

            t=s[d];

    }

    if(t==-1)

        printf("\nbest case\n");

    else

        printf("\n%d\n",t);

    t=101;

    for(d=1;d<=a;d++)

    {

        if(s[d]>=60 && s[d]<=t)

            t=s[d];

    }

    if(t==101)

        printf("worst case");

    else

        printf("%d",t);

}

 
ZeroJudge Forum