| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 597 人关注过本帖
标题:塑身菜单
取消只看楼主 加入收藏
南方姑娘
Rank: 1
等 级:新手上路
帖 子:21
专家分:5
注 册:2013-8-14
结帖率:37.5%
收藏
已结贴  问题点数:5 回复次数:1 
塑身菜单
#include<stdio.h>
int main()
{
    int i,n,s=0;
    struct menu
    {
        char name[1000];
        int hot;
    }a[15]={
        {"Steamed Rice",31},
        {"Scrambled Egg with Scallion",81},   
        {"Boiled Fish with Pickled Cabbage and Chili", 92},   
        {"Soybean Milk",92},   
        {"Steamed Jiaozi",119},   
        {"Scrambled Egg with Leek",128},
        {"Steamed Bun Stuffed with Red Bean Paste",128},
        {"Yu-Shiang Shredded Pork (Sauted with Spicy Garlic Sauce)",134},
        {"Sauted Sliced Pork with Black Fungus",143},        
        {"Hot and Sour Rice Noodles",144},   
        {"Steamed Rice Rolls",196},
        {"Sauted Sliced Pork with Pepper and Chili , Sichuan Style",231},
        {"Cold Noodles Sichuan Style",260},
        {"Fish Filets in Hot Chili Oil",239},
        {"Kung Pao Chicken",313},        
    };
    scanf("%d",&n);
    for(i=0;i<15;i++)
    {
        s=s+a[i].hot;
        if(s<=n)
        {
            printf("%s %d\n",a[i].name,a[i].hot);
        }
        else
        {
            break;
        }
    }
    return 0;
}
我想问的是为什么要把Boiled Fish with Pickled Cabbage and Chili 92
Sauted Sliced Pork with Pepper and Chili , Sichuan Style 231
Cold Noodles Sichuan Style 260
Fish Filets in Hot Chili Oil 239
Steamed Rice Rolls 196
Kung Pao Chicken 313
Hot and Sour Rice Noodles 144
Soybean Milk 92
Steamed Rice 31
Scrambled Egg with Scallion 81
Steamed Jiaozi 119
Sauted Sliced Pork with Black Fungus 143
Scrambled Egg with Leek 128
Steamed Bun Stuffed with Red Bean Paste 128
Yu-Shiang Shredded Pork (Sauted with Spicy Garlic Sauce) 134 这些按数字从小到大的顺序排列之后运行的结果才是对的,而没有排列是答案是错误的,谢谢,新手求解
搜索更多相关主题的帖子: include 
2013-08-16 19:38
南方姑娘
Rank: 1
等 级:新手上路
帖 子:21
专家分:5
注 册:2013-8-14
收藏
得分:0 
回复 3楼 木蕊
从现在开始,拟定属于你自己的健康饮食方案吧! 一份全新的健康饮食计划,将会使

你浑身充满活力。如果长时间坚持这样的饮食,那么不仅你患疾病的几率降低,而且还会比

预期寿命延长15 年。当然,随之而来的,还有你一直向往的好身材。假设供选择的菜单如

下:每份热量单位:大卡/100 克

假设供选择的菜单如下:每份热量单位:大卡/100 克

Boiled Fish with Pickled Cabbage and Chili 92

Sauted Sliced Pork with Pepper and Chili , Sichuan Style 231

Cold Noodles Sichuan Style 260

Fish Filets in Hot Chili Oil 239

Steamed Rice Rolls 196

Kung Pao Chicken 313

Hot and Sour Rice Noodles 144

Soybean Milk 92

Steamed Rice 31

Scrambled Egg with Scallion 81

Steamed Jiaozi 119

Sauted Sliced Pork with Black Fungus 143

Scrambled Egg with Leek 128

Steamed Bun Stuffed with Red Bean Paste 128

Yu-Shiang Shredded Pork (Sauted with Spicy Garlic Sauce) 134
Input
输入最大摄入热量值(要求:每份菜只能要一份)
Output
输出满足总摄入热量小于等于最大摄入热量值的菜品种类最多的组合
这个是题目,和题目要求,我的代码是正确的,但是把我所说的那里不排序的话就是错误的,why
2013-08-16 21:40
快速回复:塑身菜单
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016994 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved