test5

作者: 林之禾 | 来源:发表于2017-12-07 09:15 被阅读0次
    #include<stdio.h>
    #include<string.h>
    struct book{
        char book_name[31];
        double cost; 
        
    };
    
    int main(void){
        int n;
        scanf("%d",&n);
        struct book b[9];   
        int max_index=0,min_index=0;
        for(int i=0;i<n;i++){
                getchar();
            gets(b[i].book_name);
            scanf("%lf",&b[i].cost);
            if(b[max_index].cost<b[i].cost){
                max_index=i;
            }
            if(b[min_index].cost>b[i].cost){
                min_index=i;
            }
        }
    
        printf("%.2f, %s\n",b[max_index].cost,b[max_index].book_name);
        printf("%.2f, %s",b[min_index].cost,b[min_index].book_name);    
        
        
        
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:test5

          本文链接:https://www.haomeiwen.com/subject/ihorixtx.html