| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 959 人关注过本帖
标题:这个程序怎么写呀
只看楼主 加入收藏
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
上面是我做的,帮我看看,问题在哪里吧
2011-09-28 13:55
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:0 
还是那句老话,先看书

总有那身价贱的人给作业贴回复完整的代码
2011-09-28 13:57
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
1.scanf()漏了&
2.界面不好
3.功能有缺陷

授人以渔,不授人以鱼。
2011-09-28 13:57
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:0 
回复 10楼 csbeng001
int main(void);  哪本书教你在main后面加分号的呀?

总有那身价贱的人给作业贴回复完整的代码
2011-09-28 14:21
csbeng001
Rank: 1
来 自:湖南长沙市
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-9-13
收藏
得分:0 
回复 14楼 embed_xuel
是我错了,呵呵
2011-09-28 14:29
梦想天奇
Rank: 2
等 级:论坛游民
帖 子:12
专家分:22
注 册:2010-11-23
收藏
得分:10 
首先,要明白枚举中的常量都是整形的!可以修改如下:
#include <stdio.h>
int main(void)
{
   
    char mobel[10];
    float good =5.5;
    float bad =3.5;
    float pirce = 0.0f,mob;
    int num =0;
    printf("Please enter the mobel\"good or bad\" and the number of book!\n");
    scanf("%s",&mobel);
    if(mobel[0]=='g')mob=5.5;
    else mob=3.5;
    printf("the number:");
    scanf("%d",&num);
    pirce = mob * num;
    printf("You choose mobel is %s,the number is %d,and the price is %.2f\n",mobel,num,pirce);
    return 0;
}
2011-09-28 16:16
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.015127 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved