| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 743 人关注过本帖
标题:函數的问题求解答
取消只看楼主 加入收藏
zzy95621
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-10-26
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
函數的问题求解答
// Local Declaration
    double round2 (double);
    int NY;
    int NM;
    int PR;
    double IM, P, Q, MP, IY;

    NM = NY*12;
    IM = IY / 12 / 100;
    P  = pow(NM,(1+IM));
    Q  = (P/(P-1));
    MP = PR * IM * Q;

    // Statements
    printf("The amount of the loan (principal) :");
    scanf("%d", &PR);
    printf("Interest rate / year (per cent) :");
    scanf("%lf", &IY);
    printf("Interest rate / month (decimal) : %lf\n", IM);
    printf("Number of years : ");
    scanf("%d", &NY);

    printf("Number of Months : %d\n", &NM);
这样写可是到了计算 IM的时候怎么是0?
到NY出来的却是2686712

[此贴子已经被作者于2016-10-26 22:34编辑过]

2016-10-26 22:23
zzy95621
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-10-26
收藏
得分:0 
回复 2楼 linlulu001
我还没写完的呢,我只是试着run一下
2016-10-26 22:48
zzy95621
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-10-26
收藏
得分:0 
回复 3楼 炎天
问题是我在run的时候无论输入多少 它显示结果还是2686712
2016-10-26 22:50
zzy95621
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-10-26
收藏
得分:0 
回复 2楼 linlulu001
我只写到这样

#include <stdio.h>
#include <math.h>


int main ()
{
   

    // Local Declaration
    double round2 (double);
    int NY;
    int NM;
    int PR;
    double IM, P, Q, MP, IY;

    NM = NY*12;
    IM = IY / 12 / 100;
    P  = pow(NM,(1+IM));
    Q  = (P/(P-1));
    MP = PR * IM * Q;

    // Statements
    printf("The amount of the loan (principal) :");
    scanf("%d", &PR);
    printf("Interest rate / year (per cent) :");
    scanf("%lf", &IY);
    printf("Interest rate / month (decimal) : %lf\n", IM);
    printf("Number of years : ");
    scanf("%d", &NY);

    printf("Number of Months : %d\n", &NM);
2016-10-26 22:50
zzy95621
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-10-26
收藏
得分:0 
回复 8楼 炎天
明白了!! 感谢大大,我再作修改
2016-10-26 23:11
快速回复:函數的问题求解答
数据加载中...
 
   



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

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