Pta 编程题——查找书籍
给定 n 本书的名称和定价,本题要求编写程序,查找并输出其中定价最高和最低的书的名
称和定价。
输入格式:
输入第一行给出正整数 n(<<10),随后给出 n 本书的信息。每本书在一行中给出书名,
即长度不超过 30 的字符串,随后一行中给出正实数价格。题目保证没有同样价格的书。
输出格式:
在一行中按照“价格, 书名”的格式先后输出价格最高和最低的书。价格保留 2 位小数。
#include <stdio.h>
#include <stdlib.h>
struct book{
char name[30];
double price;
};
int order(struct book b[],int n,double[]);
int main(){
struct book b[9];
int i,n=0;
double x[9];
scanf("%d",&n);
for(i=0;i<n;i++){
//scanf("%[^]", b[i].name);
getchar();
gets(b[i].name);
scanf("%lf",&b[i].price);
}