๐Ÿ•ธ Algorithm 84

[๋ฐฑ์ค€][java][10871][X๋ณด๋‹ค ์ž‘์€ ์ˆ˜]

import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class Main { // 10871X๋ณด๋‹ค ์ž‘์€ ์ˆ˜ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] nArr = new int[n]; List lessThanX = new ArrayList(); for (int i=0; i

[๋ฐฑ์ค€][java][10951][A+B - 4]

import java.util.Scanner; public class Main { // 10951A+B - 4 public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a + b); } } } ์›๋ž˜ while(true)๋กœ ํ•ด์„œ ๋‹ต์„ ์ œ์ถœํ–ˆ๋”๋‹ˆ ๋Ÿฐํƒ€์ž„์—๋Ÿฌ๊ฐ€ ๋‚˜๋”๊ตฐ์š”. Scanner class์˜ hasNextInt()ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋˜๋Š” ๊ฑฐ์˜€์–ด์„œ ๊ณ ์ณ ๋ƒˆ๋”๋‹ˆ ๋งž์ท„์Šต๋‹ˆ๋‹ค.

[๋ฐฑ์ค€][java][10952][A+B - 5]

import java.util.Scanner; public class Main { // 10952 A+B - 5 public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int a = sc.nextInt(); int b = sc.nextInt(); int sum = a+b; if (sum == 0) { sc.close(); break; } System.out.println(sum); } } } ์ž…๋ ฅ๋œ ์ˆ˜์˜ ํ•ฉ์ด 0์ผ ๊ฒฝ์šฐ break;์œผ๋กœ while()๋ฌธ์„ ๋ฒ—์–ด๋‚˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

[๋ฐฑ์ค€][java][15552][๋น ๋ฅธ A+B]

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Main { // 15552๋น ๋ฅธ A+B public static void main(String[] args) throws IOException { BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(System..

[๋ฐฑ์ค€][java][25314][์ฝ”๋”ฉ์€ ์ฒด์œก๊ณผ๋ชฉ ์ž…๋‹ˆ๋‹ค]

import java.util.Scanner; // 25314์ฝ”๋”ฉ์€ ์ฒด์œก๊ณผ๋ชฉ ์ž…๋‹ˆ๋‹ค public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); sc.close(); for (int i = 0; i < num/4; i++) { System.out.print("long "); } System.out.print("int"); } }

๋ฐ˜์‘ํ˜•