首页 > 代码库 > 算法之路——POJ刷题(Java,持续更新中)
算法之路——POJ刷题(Java,持续更新中)
先拿一些水题来练手了
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); }}
算法之路——POJ刷题(Java,持续更新中)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。