-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc1026.java
More file actions
39 lines (32 loc) ยท 1.21 KB
/
Copy pathc1026.java
File metadata and controls
39 lines (32 loc) ยท 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
๐ก๐ก๐ก๐ก
import java.util.Scanner;
public class c1026 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("์๋ถ์ด ์
๋ ฅ: ");
String date = sc.nextLine();
sc.close();
String[] arr = date.split(":"); // ':'๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ถํ ํ์ฌ ๋ฐฐ์ด์ ์ ์ฅ
for (int i = 0; i < arr.length; i++){
String a = arr[i];
if (i == 1){ // ์
๋ ฅ๋ ๋ฐ์ดํฐ ์ค '๋ถ'๋ง ์ถ๋ ฅ
System.out.println(a);
}
}
/*String clock = sc.nextLine();
String arr[] = clock.split(":");
int arr2[] = new int[arr.length];
for(int i = 0; i < arr.length; i++){
arr2[i] = Integer.parseInt(arr[i]);
}
System.out.printf("%02d", arr2[1]);*/
}
}// end c1025
// ์
๋ ฅ ํด๋์ค์ธ Scanner ๊ฐ์ฒด ์์ฑ
// ์
๋ ฅ ํ์์ ๋ง์ถฐ ์๊ฐ์ ์
๋ ฅ๋ฐ์
// ์
๋ ฅ ์ข
๋ฃ๋์์ผ๋ฏ๋ก sc ๊ฐ์ฒด ๋ซ๊ธฐ
// ':'๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ถํ ํ์ฌ ๋ฐฐ์ด์ ์ ์ฅ
// for๋ฌธ์ ์ด์ฉํ๋ฉด์ if๋ฌธ์ผ๋ก ์กฐ๊ฑด์ ์ค์ ํ์ฌ '๋ถ'๋ง ์ถ๋ ฅ
// - i๊ฐ 0, arr[0]์ '์'
// - i๊ฐ 1, arr[1]์ '๋ถ'
// - i๊ฐ 2, arr[2]์ '์ด', for๋ฌธ ์ข
๋ฃ