hdoj 1089~1096 八道简单A+B问题 (JAVA)

来源:互联网 发布:招赢 大数据总监 编辑:程序博客网 时间:2024/05/21 21:38
1089
Sample Input
1 5
10 20
Sample Output
6

30

import java.util.*;import java.math.*;import java.io.*;public class Main1 {public static void main(String[] args) {// TODO Auto-generated method stubScanner in = new Scanner(System.in);while(in.hasNext()){int a,b;a=in.nextInt();b=in.nextInt();int c;c=a+b;System.out.println(c);}}}

1090
Sample Input
21 510 20
Sample Output
630
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);while(in.hasNext()){    int n;    n=in.nextInt();    for(int i=0;i<n;i++)    {        int a,b;        a=in.nextInt();        b=in.nextInt();        int c;        c=a+b;        System.out.println(c);    }}    }}
1091

1 510 200 0

Sample Output
630
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);while(in.hasNext()){    int a,b;    a=in.nextInt();    b=in.nextInt();    if(a==0&&b==0)    {        break;    }    else    {        System.out.println(a+b);    }}    }}

1092

Sample Input
4 1 2 3 45 1 2 3 4 50
 

Sample Output
1015
import java.util.*;import java.io.*;import java.math.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);int n;while(in.hasNext()){    n=in.nextInt();    if(n!=0)    {    int b=0;for(int i=0;i<n;i++){    int a;    a=in.nextInt();    b=b+a;}System.out.println(b);    }}    }}
1093

Sample Input
24 1 2 3 45 1 2 3 4 5
 

Sample Output
1015
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);int n;n=in.nextInt();for(int i=0;i<n;i++){    int m;    m=in.nextInt();    int b=0;    for(int c=0;c<m;c++)    {        int a;        a=in.nextInt();        b=b+a;    }    System.out.println(b);}    }}
1094

Sample Input
4 1 2 3 45 1 2 3 4 5
 

Sample Output
1015
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);while(in.hasNext()){    int n;    n=in.nextInt();    int b=0;    for(int i=0;i<n;i++)    {        int a;        a=in.nextInt();        b=b+a;    }    System.out.println(b);}    }}
1095

Sample Input
1 510 20
 

Sample Output
630
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in = new Scanner(System.in);while(in.hasNext()){    int a,b;    a=in.nextInt();    b=in.nextInt();    int c;    c=a+b;    System.out.println(c);    System.out.println( );}    }}
1096

Sample Input
34 1 2 3 45 1 2 3 4 53 1 2 3
 

Sample Output
10156
import java.util.*;import java.math.*;import java.io.*;public class Main {    public static void main(String[] args) {        // TODO Auto-generated method stubScanner in =new Scanner(System.in);while(in.hasNext()){    int n;    n=in.nextInt();    for(int i=1;i<=n;i++)    {        int a;        a= in.nextInt();        int c;        c=0;        for(int t=0;t<a;t++)        {            int b;            b=in.nextInt();            c=c+b;        }        System.out.println(c);        if(i!=n)        {        System.out.println( );        }    }}    }}


1 0