File tree Expand file tree Collapse file tree
src/main/java/algorithms/sprint0 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package algorithms .sprint0 ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import java .util .Scanner ;
6+
7+ import static org .junit .jupiter .api .Assertions .assertEquals ;
8+
9+ public class AB {
10+ public static void main (String [] args ) {
11+ Scanner sc = new Scanner (System .in );
12+ int a = sc .nextInt ();
13+ int b = sc .nextInt ();
14+ long sum = sum (a , b );
15+ System .out .println (sum );
16+ }
17+
18+ public static long sum (int a , int b ) {
19+ return a + b ;
20+ }
21+
22+ @ Test
23+ public void test () {
24+ assertEquals (5 , sum (2 , 3 ));
25+ assertEquals (-1 , sum (-2 , 1 ));
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ package algorithms .sprint0 ;// Java
2+
3+ import java .io .*;
4+ import java .util .Arrays ;
5+ import java .util .List ;
6+
7+ public class Solution {
8+ public static void main (String [] args ) throws IOException {
9+ List <Integer > arr ;
10+ try (BufferedReader reader = new BufferedReader (new InputStreamReader (System .in ))) {
11+ int n = Integer .parseInt (reader .readLine ().strip ());
12+ arr = Arrays .stream (reader .readLine ().strip ().split (" " ))
13+ .map (Integer ::parseInt )
14+ .toList ();
15+ }
16+ BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (System .out ));
17+ for (int i : arr ) {
18+ writer .write (String .valueOf (i ));
19+ writer .write (" " );
20+ }
21+ writer .flush ();
22+ }
23+
24+ }
You can’t perform that action at this time.
0 commit comments