先拿一些水题来练手了
1.POJ1000
import java.util.Scanner; /** * Created by mxcsky on 2015/1/25. */ public class POJ1000 { public static void main(String[] args){ Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); System.out.println(a + b); } }
2.POJ1003
import java.util.Scanner; /** * Created by mxcsky on 2015/1/25. */ public class POJ1003 { public static void main(String[] args){ Scanner in = new Scanner(System.in); while(true) { double m = in.nextDouble(); double sum = 0.0; int i = 1; if (m < 0.00001) { System.exit(0); } if (m <= 0.5) { System.out.println("1 card(s)"); } else { while (sum < m) { i++; sum = sum + 1.0 / i; } System.out.println((i - 1) + " card(s)"); } } } }
3.POJ1004
import java.util.Scanner; /** * Created by mxcsky on 2015/1/25. */ public class POJ1004 { public static void main(String[] args){ Scanner in = new Scanner(System.in); double sum = 0.0; for (int i = 0; i < 12; i++){ sum = sum + in.nextDouble(); } System.out.printf("$%.2f", sum/12); } }
时间: 2024-12-27 23:30:29