Chinaunix首页 | 论坛 | 博客
  • 博客访问: 41509
  • 博文数量: 71
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 726
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-24 08:29
文章分类

全部博文(71)

文章存档

2015年(71)

我的朋友

分类: Java

2015-02-17 20:36:04



  1. 1.1.1
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int a, b;
  7.         while (input.hasNextInt()) {
  8.             a = input.nextInt();
  9.             b = input.nextInt();
  10.             System.out.println(a + b);
  11.         }
  12.     }

  13. }


  1. 1.1.2
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int a, b;
  7.         int N = input.nextInt();
  8.         while (N != 0) {
  9.             a = input.nextInt();
  10.             b = input.nextInt();
  11.             System.out.println(a + b);
  12.             N--;
  13.         }
  14.     }

  15. }

  1. 1.1.3
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         while (input.hasNext()) {
  7.             int a = input.nextInt();
  8.             int b = input.nextInt();
  9.             if (a == 0 && b == 0)
  10.                 break;
  11.             System.out.println(a + b);
  12.         }
  13.     }
  14. }

  1. 1.1.4
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         int N;
  6.         int a;
  7.         int sum = 0;
  8.         Scanner input = new Scanner(System.in);
  9.         while (input.hasNext()) {
  10.             N = input.nextInt();
  11.             if (N == 0) {
  12.                 break;
  13.             } else {
  14.                 for (int i = 0; i < N; i++) {
  15.                     a = input.nextInt();
  16.                     sum += a;
  17.                 }
  18.                 System.out.println(sum);
  19.                 sum = 0;
  20.             }
  21.         }
  22.     }
  23. }

  1. 1.1.5
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int N, n;
  7.         int sum = 0;
  8.         while (input.hasNext()) {
  9.             N = input.nextInt();
  10.             for (int i = 1; i <= N; i++) {
  11.                 n = input.nextInt();
  12.                 for (int j = 1; j <= n; j++) {
  13.                     int a = input.nextInt();
  14.                     sum += a;
  15.                 }
  16.                 System.out.println(sum);
  17.                 sum = 0;
  18.             }
  19.         }
  20.     }
  21. }

  1. 1.1.6
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         int N;
  6.         int sum = 0;
  7.         Scanner input = new Scanner(System.in);
  8.         while (input.hasNext()) {
  9.             N = input.nextInt();
  10.             for (int i = 0; i < N; i++) {
  11.                 int a = input.nextInt();
  12.                 sum += a;
  13.             }
  14.             System.out.println(sum);
  15.             sum = 0;
  16.         }
  17.     }
  18. }

  1. 1.1.7
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int a, b, sum = 0;
  7.         while (input.hasNext()) {
  8.             a = input.nextInt();
  9.             b = input.nextInt();
  10.             sum = a + b;
  11.             System.out.println(sum);
  12.             System.out.println("");
  13.             sum = 0;
  14.         }
  15.     }
  16. }

  1. 1.1.8
  2. import java.util.Scanner;

  3. public class Main {

  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int N, n;
  7.         int sum = 0;
  8.         while (input.hasNext()) {
  9.             N = input.nextInt();
  10.             for (int i = 1; i <= N; i++) {
  11.                 n = input.nextInt();
  12.                 for (int j = 1; j <= n; j++) {
  13.                     int a = input.nextInt();
  14.                     sum += a;
  15.                 }
  16.                 System.out.println(sum);
  17.                 if(i<N){
  18.                     System.out.println("");
  19.                 }
  20.                 sum = 0;
  21.             }
  22.         }
  23.     }
  24. }

阅读(191) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~