N 11 2 N 9
import java.util.Scanner; /** * @author jwang1 Success Factors */ public class Main { public static void main(String[] args) { boolean flag1 = false; boolean flag2 = false; boolean flag3 = false; boolean flag4 = false; boolean flag5 = false; int a1 = 0, a2 = 0, a3 = 0, a5 = 0; double a4 = 0; int factor = 1; int k = 0; int t = 0; int A = 0; int mod = 0; Scanner cin = new Scanner(System.in); int n = cin.nextInt(); for (int i = 0; i < n; i++) { t = cin.nextInt(); A = t / 5; mod = t % 5; switch (mod) { case 0: if (A % 2 == 0) { a1 += t; flag1 = true; } break; case 1: a2 += factor * t; factor = -factor; flag2 = true; break; case 2: a3++; flag3 = true; break; case 3: a4 += t; k++; flag4 = true; break; case 4: if (a5 < t) { a5 = t; flag5 = true; } break; } } if (flag1) System.out.print(a1 + " "); else System.out.print("N "); if (flag2) System.out.print(a2 + " "); else System.out.print("N "); if (flag3) System.out.print(a3 + " "); else System.out.print("N "); if (flag4) System.out.printf("%.1f ", a4 / k); else System.out.print("N "); if (flag5) System.out.println(a5); else System.out.println("N"); } }
1012. 数字分类 (20),布布扣,bubuko.com
原文地址:http://blog.csdn.net/jason_wang1989/article/details/26135501