test5
2017-12-07 本文已影响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;
}