PS

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.close(); for(int i = 1; i0 ; j--) { if(i
public class Main { public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String sdfD = sdf.format(date); System.out.println(sdfD); } } Date์— ๊ด€ํ•œ ์ฝ”๋“œ๋ฅผ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์‹œ ๋ณต์Šตํ•˜๊ณ ์ž ๋ธ”๋กœ๊ทธ์— ๊ธ€์„ ๋‚จ๊ธด๋‹ค.
public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long n = scanner.nextLong(); long j = scanner.nextLong(); System.out.println(Math.abs(j-n)); scanner.close(); } } ์ ˆ๋Œ“๊ฐ’์— ๋Œ€ํ•œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋‹ค. int ๋ฐ์ดํ„ฐ ํƒ€์ž…์„ ์‚ฌ์šฉํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋Š”๋ฐ, ์ ˆ๋Œ“๊ฐ’์œผ๋กœ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค๋ณด๋‹ˆ N, M์„ ํ•ฉ์นœ ๊ฑฐ๋ฆฌ๋Š” int ์ด์ƒ์˜ ๋ฐ์ดํ„ฐ ํƒ€์ž…์ด ํ•„์š”ํ•˜๋‹ค. (long) import java.util.Scanner; public class Main { public static void main(Stri..
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); if(n>=0 && n
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); int y = scanner.nextInt(); int x1 = x/y; int y1 = x%y; System.out.println(x1); System.out.println(y1); scanner.close(); } } ๋ฌธ์ œ๋ฅผ ๋ณด๊ณ  ์ œ์ถœ์„ ํ–ˆ๋Š”๋ฐ, ๊ณ„์† ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค. ๋ถ„๋ช… ํ‹€๋ฆด๋ฆฌ๊ฐ€ ์—†๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋ฌธ์ œ๋ฅผ ๋‹ค์‹œ ์‚ดํŽด๋ณด์•˜๋‹ค. ๋ฌธ์ œ๋ฅผ ํ™•์ธํ•˜๋‹ˆ ์•„์ฃผ ํฐ ์ˆซ์ž๋ฅผ ๋„ฃ์–ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์ด์—ˆ๋‹ค. int, long ๋ณด๋‹ค ํฐ ์ˆ˜๋ฅผ ๋„ฃ์„..
โœจ Constructor & Basic Attribute private Node head; private Node tail; private int size; private class Node{ private int value; private Node next; private Node(int data) { this.value = data; this.next = null; } public String toString() { return String.valueOf(this.value); } } ์ œ์ผ ์•ž์— ์žˆ๋Š” ๋…ธ๋“œ, ๋’ค์— ์žˆ๋Š” ๋…ธ๋“œ, size๋ฅผ ์ •์˜ํ•œ๋‹ค. ๋˜ํ•œ ๋…ธ๋“œ๋ฅผ ๋‚ด๋ถ€ class๋กœ ์ƒ์„ฑํ•˜์—ฌ contructor๋กœ ๊ฐ์ฒด ์ƒ์„ฑ ์‹œ ์ดˆ๊ธฐํ™”ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. โœจ addFirst(int data) public vo..
๋“œ๋””์–ด ๋ธ”๋กœ๊ทธ์— ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ธ€์„ ์“ด ์ด์œ ,, LinkedList์— ๋Œ€ํ•ด์„œ ์„ค๋ช…ํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€ ์—ฐ๊ฒฐ์ด ๋ฌด์—‡์ธ๊ฐ€, ํ”„๋กœ๊ทธ๋ž˜๋ฐ์œผ๋กœ ํ‘œํ˜„ํ•˜๋Š”๊ฐ€? cpu: ๊ณ„์‚ฐํ•˜๊ณ  ์—ฐ์‚ฐ, ์ฒ˜๋ฆฌ ์†๋„๊ฐ€ storage, memory, cpu ์ค‘์— ๊ฐ€์žฅ ๋น ๋ฆ„ storage: HDD, SSD ํŒŒ์ผ, ๋ฐ์ดํ„ฐ ๋“ฑ์„ ์ €์žฅ, ๊ฐ€๊ฒฉ์ด ์ €๋ ด, ์šฉ๋Ÿ‰์ด ํฌ๊ณ , ๋น„ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ ๋ฉ”๋ชจ๋ฆฌ: ๊ธฐ์–ต์„ ๋‹ด๋‹น, ์šฉ๋Ÿ‰์ด ์•„์ฃผ ์ ์Œ, ํœ˜๋ฐœ์„ฑ ๋ฉ”๋ชจ๋ฆฌ, storage ๋ณด๋‹ค ํ›จ์”ฌ ๋” ๋น ๋ฅด๊ฒŒ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ณ  ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ. cpu๊ฐ€ storage์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ๋‹ค๊ฐ€ ์“ฐ๊ฒŒ ๋˜๋ฉด ์‹œ๊ฐ„์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค. cpu๊ฐ€ ๊ณ„์‚ฐ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” storage์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋“ค์„ memory๋กœ ๊ฐ€์ ธ์˜จ ๋‹ค์Œ์— memory๊ฐ€ cpu์—๊ฒŒ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋Š”๊ฒŒ ๋น ๋ฅด..
ArrayList๋ฅผ ์ง์ ‘ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜์—ฌ int ํ˜• ArrayList๋ฅผ ๋‚˜ํƒ€๋‚ด ๋ณด๊ณ ์ž ํ•œ๋‹ค. โœจ Constructor & Basic Attribute private int[] elementData; // ๊ฐ’ ๋„ฃ์„ ๊ณณ private int size; // arraylist size private int currentCapacity; // ํ˜„์žฌ arraylist ํฌ๊ธฐ private int initCapacity = 10; // ์ตœ์ดˆ arraylist ํฌ๊ธฐ //constructor public MyArrayList() { this.elementData = new int[initCapacity]; this.size = 0; this.currentCapacity = initCapacity; } ๊ฐ’ ๋„ฃ์„ eleme..
โœจ ArrayList ๋‚ด๋ถ€์ ์œผ๋กœ ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ โœจ ArrayList Insert & Delete arrayList.add(10); arrayList.add(20); arrayList.add(30); arrayList.add(40); 20 ์ž๋ฆฌ์— 50์„ ๋„ฃ๊ณ  ์‹ถ๋‹ค๋ฉด, ๋งจ ๋’ค์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ๋’ค๋กœ ์ด๋™ํ•˜์—ฌ ์ž๋ฆฌ๋ฅผ ๋งŒ๋“  ํ›„ 50์˜ ๊ฐ’์„ ๋„ฃ๋Š”๋‹ค. -> ์‚ญ์ œ๋„ ์ด์™€ ๋งˆ์ฐฌ๊ฐ€์ง€ โœจ ArrayList Get ๋ฐ์ดํ„ฐ๋ฅผ ์ฐจ๋ก€๋Œ€๋กœ ์ €์žฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ์ดํ„ฐ์˜ ์œ„์น˜๋ฅผ ์•Œ๊ณ  ์žˆ์Œ. index๋ฅผ ์ด์šฉํ•˜์—ฌ List์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋น ๋ฅด๊ฒŒ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค . โœจ ArrayList Pros and Cons [์žฅ์ ] ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ฌ ๋•Œ ๋น ๋ฅด๊ฒŒ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ [๋‹จ์ ] ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•˜๋ฉด ํ•˜๋‚˜์”ฉ ๋‹ค ์˜ฎ๊ฒจ์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‹œ๊ฐ„์ด..
โœจ List vs Array ์ €์žฅ ๋‘˜ ๋‹ค, ์ˆœ์„œ๋Œ€๋กœ ์ €์žฅ๋˜๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ์ค‘๋ณตํ•˜์—ฌ ์ €์žฅ ๊ฐ€๋Šฅ Array๋Š” ์–ด๋–ค ๋ฐ์ดํ„ฐ ์ €์žฅ ์œ„์น˜๊ฐ€ ์ค‘์š”ํ•จ. (index) ์ฃผ์†Œ๋ฅผ ๊ฐ–๊ณ  ๋ฐ”๋กœ ์ฐพ์•„๊ฐˆ ์ˆ˜ ์žˆ์Œ array[0] = 10; array[1] = 20; array[2] = 30; array[3] = 40; array์—์„œ index 3์— 50์˜ ๊ฐ’์„ ๋„ฃ๊ฒŒ ๋˜๋ฉด 40 ์œ„์— ๋ฎ์–ด์”Œ๊ฒŒ ๋œ๋‹ค. array[0] = 10; array[1] = 20; array[2] = 30; array[3] = 50; List๋„ index๊ฐ€ ์ค‘์š”ํ•˜์ง€๋งŒ, element์˜ ๋‹ค์Œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฌด์—‡์ธ์ง€๊ฐ€ ๋” ์ค‘์š”ํ•จ. ๋ฐ์ดํ„ฐ๊ฐ€ ์ €์žฅ๋˜์–ด ์žˆ๋Š” ์ˆœ์„œ๊ฐ€ ์ค‘์š”ํ•จ. list[0] = 10; list[1] = 20; list[2] = 30; list[3] = 40; ar..
chaerlo127
'PS' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (4 Page)