530 2

[新手尝试] 请大家帮忙找一下程序中的问题,为什么得不出想要的输出?是哪里存在问题呢? [推广有奖]

  • 0关注
  • 0粉丝

小学生

0%

还不是VIP/贵宾

-

威望
0
论坛币
10 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
56 点
帖子
3
精华
0
在线时间
4 小时
注册时间
2018-1-5
最后登录
2020-2-7

楼主
你看见过我的小熊吗 发表于 2020-2-3 10:47:35 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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;
}

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝


沙发
你看见过我的小熊吗 发表于 2020-2-4 12:03:58
请大家帮忙找一下程序中的问题,为什么得不出想要的输出?是哪里存在问题呢?

藤椅
你看见过我的小熊吗 发表于 2020-2-4 12:04:26
请大家帮忙找一下程序中的问题,为什么得不出想要的输出?是哪里存在问题呢?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2026-1-1 01:14