#include<stdio.h>
struct book{
char name[80];
double price;
};
int main()
{
int i,n,j;
double max,min;
char a,b;
struct book s[10];
printf("Input n:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Input the name,price of the %d book:",i+1);
scanf("%s%lf",s[i].name,&s[i].price);
}
max=s[0].price,min=s[0].price;
a=s[0].name,b=s[0].name;
for(i=0;i<n;i++)
{
if(max<s[i].price)
a=s[i].name;
max=s[i].price;
}
for(j=0;j<n;j++)
{
if(min>s[j].price)
b=s[j].name;
min=s[j].price;
}
printf("The book with the max price:%s,%.1f\n",a,max);
printf("The book with the min price:%s,%.1f\n",b,min);
return 0;
}
为什么无法输出结果