/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int[] i_arr = new int[scan.nextInt()];
for(int i = 0 ; i < i_arr.length; i++)
i_arr[i] = scan.nextInt();
System.out.println(Arrays.stream(i_arr).sum());
clojure코드도 한번 써봤다
(use '[clojure.string :only (split trim)])
(let [
n (Integer/parseInt (read-line))
arr_t (split (read-line) #"\s+")
arr (map #(Integer/parseInt %) arr_t)]
(println (reduce + arr))
)
비교를하면
Arrays.stream(i_arr).sum()
이것과
(reduce + arr)
이것의 차이
댓글 없음:
댓글 쓰기