#include <stdio.h>
#include <string.h>
struct books{ /* 构造结构体 */
char name; /* 名称 */
int price; /* 定价 */
}b,book[10];
int search_book(struct books *p);
int main()
{
int i;
for(i=0;i<10;i++) /*键盘输入是本书的名称和价格*/
{
scanf("%c,%d\n",&book[i].name,&book[i].price);
}
search_book(struct books book);/*调用搜索结果*/
return 0;
}
int search_book(struct books *p) /*查书*/
{
int i;
scanf("%c\n",b.name);
for(i=0;i<10;i++)
{
if(b.name==p->name)
printf("%c,%d\n",book[i].name,book[i].price);
p++;
}
return 0;
}
int arrange_book(struct books a[])
{
int i,temp;
char tempc;
for(i=0;i<10;i++) /*输出价格最高的书*/
{
if(a[i].price<=a[i+1].price)
{
tempc=a[i].name;
temp=a[i].price;
a[i].name=a[i+1].name;
a[i].price=a[i+1].price;
a[i+1].name=tempc;
a[i+1].price=temp;
}
}
printf("%c,%d\n",a[i].name,a[i].price);
for(i=0;i<10;i++) /*输出价格最低的书*/
{
if(a[i].price>=a[i+1].price)
{
tempc=a[i].name;
temp=a[i].price;
a[i].name=a[i+1].name;
a[i].price=a[i+1].price;
a[i+1].name=tempc;
a[i+1].price=temp;
}
}
printf("%c,%d\n",a[i].name,a[i].price);
return 0;
}