| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 717 人关注过本帖
标题:困扰了好几天的 scanf 输入函数应用
取消只看楼主 加入收藏
lanskyxti
Rank: 1
等 级:新手上路
帖 子:14
专家分:4
注 册:2014-8-29
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:1 
困扰了好几天的 scanf 输入函数应用
程序代码:
#include<stdio.h>
#include<stdlib.h>

int main(viod)
{
    double price,discount,new_discount;
    float cost_discount=0.38;
    printf("产品价格 :");
    scanf("%d",&price);//getchar();
    printf("产品折扣 :");
    scanf("%f",&discount);//getchar();
    printf("产品价格是%d,折扣是%.2f,成本折扣是%f.\n",price,discount,discount-cost_discount);
    double profit=price*(discount-cost_discount);
    printf("产品利润是%d:\n",profit);
    printf("产品新折扣是 :");//getchar();
    scanf("%f",&new_discount);
    double profit1=price*(new_discount-cost_discount);
    if(profit>=profit1)
    printf("前数量= %d 数量.\n",profit/profit1);
    else
    printf("亏本.\n");
    system("pause");
    return 0;
}
算出来的结果不对,是scanf函数调入了什么,请各位帮忙指正那里错了,谢谢!
搜索更多相关主题的帖子: price color discount 
2014-09-20 16:31
lanskyxti
Rank: 1
等 级:新手上路
帖 子:14
专家分:4
注 册:2014-8-29
收藏
得分:0 
总结
总结:printf函数有些编译器不支持变量计算,输出的只是变量的值。
2014-09-24 16:32
快速回复:困扰了好几天的 scanf 输入函数应用
数据加载中...
 
   



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

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