UVA 10783 Java

  1. import java.util.*;
  2. public class main{
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int times = sc.nextInt();
  6. for(int i = 0; i < times; i++)
  7. {
  8. int a = sc.nextInt();
  9. int b = sc.nextInt();
  10. int sum = 0;
  11. for(int j = a; j <= b; j++)
  12. if(j % 2 != 0)
  13. sum += j;
  14. System.out.println(String.format("Case %d: %d", i+1, sum));
  15. }
  16. }
  17. };
  18.  

留言

這個網誌中的熱門文章

C# 井字遊戲