编程介的小学生
2019-01-10 00:35
采纳率: 92.6%
浏览 1.2k

这里关于汇率的计算问题,采用C语言怎么实现汇率的计算的呢?

Problem Description
Now that the Loonie is hovering about par with the Greenback, you have decided to use your $1000 entrance scholarship to engage in currency speculation. So you gaze into a crystal ball which predicts the closing exchange rate between Canadian and U.S. dollars for each of the next several days. On any given day, you can switch all of your money from Canadian to U.S. dollars, or vice versa, at the prevailing exchange rate, less a 3% commission, less any fraction of a cent.
Assuming your crystal ball is correct, what's the maximum amount of money you can have, in Canadian dollars, when you're done?

Input
The input contains a number of test cases, followed by a line containing 0. Each test case begins with 0 <d ≤ 365, the number of days that your crystal ball can predict. d lines follow, giving the price of a U.S. dollar in Canadian dollars, as a real number.

Output
For each test case, output a line giving the maximum amount of money, in Canadian dollars and cents, that it is possible to have at the end of the last prediction, assuming you may exchange money on any subset of the predicted days, in order.

Sample Input
3
1.0500
0.9300
0.9900
2
1.0500
1.1000
0

Sample Output
1001.60
1000.00

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • threenewbee 2019-12-29 00:37
    已采纳
    已采纳该答案
    打赏 评论
  • dengcsdn2015 2019-01-10 07:51
    打赏 评论
  • weixin_43291892 2019-01-10 10:28

    一、直接标价法:
    汇率升贬值率=(旧汇率/新汇率-1)*100
    二、间接标价法:
    汇率升贬值率=(新汇率/旧汇率-1)*100
    结果是正值表示本币升值,负值表示本币贬值。
    汇率是指一国货币与另一国货币的比率或比价,或者说是用一国货币表示的另一国货币的价格。汇率变动对一国进出口贸易有着直接的调节作用。
    在一定条件下,通过使本国货币对外贬值,即让汇率下降,会起到促进出口、限制进口的作用;反之,本国货币对外升值,即汇率上升,则起到限制出口、增加进口的作用。

    打赏 评论

相关推荐 更多相似问题