课上老师出的一道题,关于编写简单程序的,各位大神看来应该很简单,但是我刚开始学太笨了,求指教!翻译成中文大概就是要编写一个找钱的程序,比如要找6.42,这个程序要显示出需要几个5元,几个2元,几个1元,几个0.5,几个0.1,几个0.01······
Question 3 Make change. Suppose there are types of coins, 5 mops, 2 mops, 1 mop, 50 cents, 10 cents and 1 cent. You are asked to write a function for a cashier to make changes. For example, how many 5-mop, 2-mop, 1-mop, 50-cent, 10-cent, and 1-cent coins are needed for 8.47 mops? a. Test your function for 6.42 mops. b. Sometimes, cashier receives Hong Kong dollars, or Renminbi. Modify your function to include currency rates, e.g., 1 HKD=1.03 MOP, and 1 YUAN=1.18 MOP. Test your function for 100.5 Yuan, and 130.2 HKD.
|