找零钱

http://202.117.21.117/xjoj/problem_html/294.html
 1 //author:pz
 2 
 3 import java.awt.*;
 4 import java.io.*;
 5 import java.util.*;
 6 import java.lang.*;
 7 
 8 public class Main {
 9     public static void main(String[] args) throws IOException {
10         Scanner in = new Scanner(new BufferedInputStream(System.in));
11         while (in.hasNextDouble()) {
12             double yin = in.nextDouble();
13             int c = 0;
14             int y = (int) (yin * 10);
15             int c1000 = y / 1000;
16             c += c1000;
17             y %= 1000;
18             int c500 = y / 500;
19             c += c500;
20             y %= 500;
21             int c200 = y / 200;
22             c += c200;
23             y %= 200;
24             int c100 = y / 100;
25             c += c100;
26             y %= 100;
27             int c50 = y / 50;
28             c += c50;
29             y %= 50;
30             int c10 = y / 10;
31             c += c10;
32             y %= 10;
33             int c5 = y / 5;
34             c += c5;
35             y %= 5;
36             int c1 = y;
37             c += c1;
38             System.out.println(c);
39 
40         }
41     }
42 
43 }
原文地址:https://www.cnblogs.com/pengzheng/p/3071755.html