| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 959 人关注过本帖
标题:这个程序怎么写呀
取消只看楼主 加入收藏
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:7 
这个程序怎么写呀
一个产品有两个版本,一个高级,5.5元,标准3.5元。提示用户输入产品版本和数量 ,然后根据输入的信息,算出价格。
该用什么函数?
搜索更多相关主题的帖子: 产品 函数 用户 
2011-09-28 11:35
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
还有没有其它的,比如枚举法,我是看的书上的习题,书上还没有讲到这些内容。
2011-09-28 11:58
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
而且这个程序,有一个用户,输入要哪个版本的过程,if 和switch 语言都没有这样一个过程吧
2011-09-28 11:59
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
#include <stdio.h>
int main(void)
{
    enum mobel{good,bad};
    float good =5.5;
    float bad =3.5;
    float pirce = 0.0f;
    int num =0;
    printf("Please enter the mobel\"good or bad\" and the number of book!");
    scanf("%c",mobel);
    scanf("%d",num);
    pirce = mobel * num;
    printf("You choose mobel is %c,the number is %d,and the price is %.2f\n",mobel,num,pirce);
    return 0;
}
    帮我看看,这里哪里有问题,枚举函数不是很明白怎么用,给点提示,谢谢

[ 本帖最后由 csbeng001 于 2011-9-28 14:24 编辑 ]
2011-09-28 13:54
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
上面是我做的,帮我看看,问题在哪里吧
2011-09-28 13:55
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
回复 14楼 embed_xuel
是我错了,呵呵
2011-09-28 14:29
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
回复 16楼 梦想天奇
char mobel[10];
        if(mobel[0]=='g')mob=5.5;
    else mob=3.5;
请问这句,是什么意思呢,不理解,[]的意思,还没有看到过,谢谢
2011-09-28 16:32
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
#include <stdio.h>
int main(void)
{
    double total_price =0;
    int type =0;
    int number =0;
    const double type1_price =3.5;
    const double type2_price =5.5;

    printf("Please choose the type (1 or 2): \n");
    scanf("%d",&type);
    printf("Enter the number: ");
    scanf("%d",&number);
    total_price = number * (type1_price + (type -1)*(type2_price-type1_price));
    printf("You choose %d of type %d ,and shold pay $%.2f .\n",number ,type ,total_price);
    return 0;
}

这是书上给出的答案,供大家参考一下,我认为,是我把问题想的太复杂了,走了岔路
2011-09-29 11:37
快速回复:这个程序怎么写呀
数据加载中...
 
   



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

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