반응형
1017번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(br.readLine());
System.out.print(number + " " + number + " " + number);
}
}
1018번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] time = br.readLine().split(":");
System.out.print(time[0] + ":" + time[1]);
}
}
1019번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] time = br.readLine().split("\\.");
String year = time[0];
String month = time[1];
String day = time[2];
StringBuilder sb = new StringBuilder();
if (year.length() == 2) {
sb.append("00" + year);
} else {
sb.append(year);
}
if (month.length() == 1) {
sb.append("." + "0" + month);
} else {
sb.append("." + month);
}
if (day.length() == 1) {
sb.append("." + "0" + day);
} else {
sb.append("." + day);
}
System.out.print(sb.toString());
}
}
1020번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] numbers = br.readLine().split("-");
System.out.print(numbers[0] + numbers[1]);
}
}
반응형
'알고리즘 > 코드업 기초 100제' 카테고리의 다른 글
[JAVA]코드업 1026번 ~ 1030번 (0) | 2021.04.29 |
---|---|
[JAVA]코드업 1021번 ~ 1025번 (0) | 2021.04.27 |
[JAVA]코드업 1011번 ~ 1015번 (0) | 2021.04.27 |
[JAVA]코드업 1006번 ~ 1010번 (0) | 2021.04.27 |
[JAVA]코드업 1001번 ~ 1005번 (0) | 2021.04.27 |