Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.StringTokenizer;
- public class SumTest {
- public static void main(String[] args) {
- MyScanner sc = new MyScanner();
- int sum = 0;
- int N = sc.nextInt();
- for (int i = 0; i < N; i++) {
- sum += sc.nextInt();
- }
- System.out.println(sum);
- }
- }
- // Folositi clasa aceasta pentru o citire mai rapida
- // sursa: http://codeforces.com/blog/entry/7018
- class MyScanner {
- BufferedReader br;
- StringTokenizer st;
- public MyScanner() {
- br = new BufferedReader(new InputStreamReader(System.in));
- }
- String next() {
- while (st == null || !st.hasMoreElements()) {
- try {
- st = new StringTokenizer(br.readLine());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return st.nextToken();
- }
- int nextInt() {
- return Integer.parseInt(next());
- }
- long nextLong() {
- return Long.parseLong(next());
- }
- double nextDouble() {
- return Double.parseDouble(next());
- }
- String nextLine(){
- String str = "";
- try {
- str = br.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return str;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement