struct book{
char ch[3];
int price;
};
void find(struct book book[],int i,struct book* min,struct book* max){
struct book* book2;
min=book;
max=book;
book2=book;
int k;
for(k=0;k<i;k++,book2++){
if((book2->price)>=(max->price)){
*max=*book2;
}
if((book2->price)<=(min->price)){
*min=*book2;
}
}
}
int main(void){
struct book b[3],*max,*min;
int i;
for(i=0;i<3;i++){
printf("请输入书名:\n");
scanf("%s",&b[i].ch);
printf("请输入价格:\n");
scanf("%d",&b[i].price);
}
max=b;//为什么一定要赋值?
min=b;//为什么一定要赋值?
find(b,3,min,max);
printf("min is %s,price is %d",min->ch,min->price);
printf("max is %s,price is %d",max->ch,max->price);
return 0;
}


雷达卡


京公网安备 11010802022788号







