Created
November 29, 2017 03:16
-
-
Save ajaybgupta/f8b5e93f08cddeb10314e02e9b1a6232 to your computer and use it in GitHub Desktop.
Hacker Rank - Reading Input Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simpleArraySum(n: Int, ar: Array[Int]): Int = { | |
ar.sum | |
} | |
def main(args: Array[String]) { | |
val sc = new java.util.Scanner (System.in); | |
var n = sc.nextInt(); | |
var ar = new Array[Int](n); | |
for(ar_i <- 0 to n-1) { | |
ar(ar_i) = sc.nextInt(); | |
} | |
val result = simpleArraySum(n, ar); | |
println(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To read string directly from screen
val s = sc.next()