์ถœ๋ ฅ

โœ… ๋ฌธ์ œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ณ„์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋ฐฐ์—ด ์ธ๋ฑ์Šค์˜ ์ˆ˜ ๋งŒํผ ๋ณ„ ์ฐ๊ธฐ โœ… ์ฝ”๋“œ import java.util.Scanner; public class bonus04 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] cc = new int[5]; // ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ์ˆซ์ž์ž…๋ ฅ ๋ฐ›๊ธฐ for (int i = 0; i < cc.length; i++) { System.out.print(i + "๋ฒˆ์งธ ๋ณ„์˜ ์ˆ˜ : "); cc[i] = sc.nextInt(); } // ๋ฐฐ์—ด ์ˆœํšŒ for (int i = 0; i < cc.length; i++) { System.out.print(cc[i] + ":"); // ๋ณ„ ์ถœ๋ ฅ fo..
โœ… ๋ฌธ์ œ ๊ณ„์‚ฐ๊ธฐ ๋งŒ๋“ค๊ธฐ โœ… ์ถ”๋ก  ๊ณผ์ • ๋‘ ๊ฐœ์˜ ์ •์ˆ˜์™€ ์—ฐ์‚ฐ์ž๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„์„œ ํ•ด๋‹น ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ ๊ตฌํ˜„ ์ฝ”๋“œ์ด๋‹ค. ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์ด 3๊ฐœ์ด๊ณ , int ํ˜•์œผ๋กœ ๊ฒฐ๊ณผ๋ฅผ return ํ•ด ์ฃผ๋ฉด ๋˜๋Š” ์‰ฌ์šด ๋ฌธ์ œ์ด๋‹ค. ๋ฉ”์„œ๋“œ๋Š” Main ์˜์—ญ ๋ฐ–์—์„œ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ๊ฒฐ๊ณผ ๊ฐ’๋งŒ Main์˜์—ญ ์•ˆ์—์„œ ์ถœ๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค. โœ… ์ฝ”๋“œ public class bonus03 { public static void main(String[] args) { System.out.println(cal(4, 7, '*')); } public static int cal(int num1, int num2, char op) { if (op == '+') { return num1 + num2; } if (op == '-') { return num1..
โœ… ๋ฌธ์ œ A, B ์ˆซ์ž๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.A-B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.A์™€ B๊ฐ€ ๋ชจ๋‘ 0์„ ์ž…๋ ฅ ๋ฐ›์œผ๋ฉด ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋œ๋‹ค. โœ… ์ฝ”๋“œ import java.util.Scanner; public class bonus01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.print("A ์ž…๋ ฅ >> "); int num1 = sc.nextInt(); System.out.print("B ์ž…๋ ฅ >> "); int num2 = sc.nextInt(); System.out.println("๊ฒฐ๊ณผ >> " + (num1 - num2)); if (num1 == 0 && num2 == 0) { brea..
โœ… ๋ฌธ์ œ ๊ฐœ ์ถœ๋ ฅํ•˜๊ธฐโ€‹ ์ด์Šค์ผ€์ดํ”„ ์ฝ”๋“œ(Escape Sequance)๋ฅผ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•œ ๋ฌธ์ œ โ€‹๐Ÿ“ฅ ์ž…๋ ฅ ์—†์Œ โ€‹๐Ÿ“ฅ ์ถœ๋ ฅ ๊ฐœ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค โ€‹ ๐Ÿ’ก ํ’€์ด ์ด ๋ฌธ์ œ๋Š” ๊ณ ์–‘์ด ๋ฌธ์ œ๋ž‘ ๋งค์šฐ ์œ ์‚ฌํ•˜๋‹ค. ์ด์Šค์ผ€์ดํ”„ ์ฝ”๋“œ ์ •๋ฆฌ โ–ผ
โœ… ๋ฌธ์ œ ๋ฌธ์ž์—ด ํ˜•ํƒœ์˜ 2์ง„์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ 10์ง„์ˆ˜๋กœ ๋ฐ”๊พธ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. โœ… ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); int base = 1; int result = 0; for (int i = str.length()-1 ; i >= 0; i--) { if(str.charAt(i) == '1'){ result += base; } base *= 2; } System.out.println(result); } } โœ… ์ด์ง„์ˆ˜๋ฅผ ์‹ญ์ง„์ˆ˜๋กœ ๋ฐ”๊พธ๋Š” ๋ฒ• ์ด์ง„์ˆ˜๋Š” 0๋˜๋Š” 1๋กœ ์ด๋ฃจ์–ด์ ธ ..
โœ… ๋ฌธ์ œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ๋Œ€์‹œ('_') ๋ฌธ์ž๋กœ ๊ตฌ์„ฑ๋œ ํ˜•ํƒœ์˜ ์ˆซ์ž๋ฅผ ์ฃผ์–ด์ง„ ์ˆซ์ž์™€ ๊ฐ™์ด ์ถœ๋ ฅํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ๋˜๊ธฐ ๋˜๋Š” ๋Œ€์‹œ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ผ. โœ… ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] c = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 }; System.out.print("์ฒซ์ž๋ฆฌ 0์„ ์ œ์™ธํ•œ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” >> "); String nums = sc.nextLine(); int result = 0; for (int i = 0; i < nums.length(); i++) { r..
โœ… ๋ฌธ์ œ [์ž…๋ ฅ] 1. N๊ณผ X๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. 2. N๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. (๋ฐ˜๋ณต๋ฌธ) [์ถœ๋ ฅ] 3. N๊ฐœ์˜ ์ˆซ์ž ์ค‘ X๋ณด๋‹ค ์ž‘์€ ์ˆ˜๋งŒ ์ถœ๋ ฅํ•œ๋‹ค. โœ… ์ฝ”๋“œ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("N ์ž…๋ ฅ >> "); int n = sc.nextInt(); System.out.print("X ์ž…๋ ฅ >> "); int x = sc.nextInt(); int[] nums = new int[n]; for (int i = 0; i < n; i++) { System.out.print((i+1) + "๋ฒˆ..
โœ… ๋ฌธ์ œ ์•„๋ž˜์™€ ๊ฐ™์€ 2์ฐจ์› ๋ฐฐ์—ด์„ ์™ผ์ชฝ์œผ๋กœ 90๋„ ํšŒ์ „ํ•˜์—ฌ ์ถœ๋ ฅํ•˜์‹œ์˜ค. โœ… ์ฝ”๋“œ public class Main { public static void main(String[] args) { int[][] num = new int[5][5]; int count = 1; for (int i = 0; i < num.length; i++) { for (int j = 0; j < num.length; j++) { num[i][j] = count++; } } // ์›๋ณธ๋ฐฐ์—ด ์ถœ๋ ฅ for (int i = 0; i < num.length; i++) { for (int j = 0; j < num.length; j++) { System.out.print(num[i][j] + "\t"); } System.out.printl..
DAIN_CHOI
'์ถœ๋ ฅ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก