-
Notifications
You must be signed in to change notification settings - Fork 5
240516 이현희 0x02 풀이 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
|
|
||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int n = sc.nextInt(); | ||
| int x = sc.nextInt(); | ||
|
|
||
| for (int i = 0; i < n; i++) { | ||
| int inputData = sc.nextInt(); | ||
| if (inputData < x) { | ||
| System.out.print(inputData + " "); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
|
|
||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int n = sc.nextInt(); | ||
|
|
||
| // 위 | ||
| for (int i = 1; i < n; i++) { | ||
| // 빈칸 | ||
| for (int j = 0; j < n - i; j++) { | ||
| System.out.print(" "); | ||
| } | ||
| // 별 | ||
| for (int j = 0; j < 2 * i - 1; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
|
|
||
| // 가운데 | ||
| for (int i = 0; i < 2 * n - 1; i++) { | ||
| System.out.print("*"); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전 가운데까지 포함해서 위~ / 아래 이렇게 구현했었는데, |
||
| System.out.println(); | ||
|
|
||
| // 아래 | ||
| for (int i = n - 1; i > 0; i--) { | ||
| // 빈칸 | ||
| for (int j = 0; j < n - i; j++) { | ||
| System.out.print(" "); | ||
| } | ||
| // 별 | ||
| for (int j = 0; j < 2 * i - 1; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
|
|
||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int n = sc.nextInt(); | ||
|
|
||
| for (int i = 1; i < n; i++) { | ||
| for (int j = 0; j < i; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| for (int j = 0; j < 2 * (n - i); j++) { | ||
| System.out.print(" "); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전 이부분 구현을 똑바로 못했어서 |
||
| for (int j = 0; j < i; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
|
|
||
| for (int i = 0; i < 2 * n; i++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
|
|
||
| for (int i = n - 1; i > 0; i--) { | ||
| for (int j = 0; j < i; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| for (int j = 0; j < 2 * (n - i); j++) { | ||
| System.out.print(" "); | ||
| } | ||
| for (int j = 0; j < i; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
|
|
||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| int n = sc.nextInt(); | ||
|
|
||
| for (int i = n - 1; i > 0; i--) { | ||
| for (int j = 0; j < n - i - 1; j++) { | ||
| System.out.print(" "); | ||
| } | ||
|
|
||
| for (int j = 0; j < 2 * i + 1; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 윗 삼각형 부분을 이런식으로 구현했습니다. for (int i = 0; i <n; i++) { // 윗 삼각형 큰 반복문 부분에서 저는 i값이 0부터 증가하는 것으로 구현하였는데, |
||
|
|
||
| for (int i = 0; i < n - 1; i++) { | ||
| System.out.print(" "); | ||
| } | ||
| System.out.println("*"); | ||
|
|
||
| for (int i = 1; i < n; i++) { | ||
| for (int j = 0; j < n - i - 1; j++) { | ||
| System.out.print(" "); | ||
| } | ||
| for (int j = 0; j < 2 * i + 1; j++) { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import java.util.*; | ||
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
|
|
||
| Scanner sc = new Scanner(System.in); | ||
|
|
||
| List<Integer> arr = new ArrayList<>(); | ||
|
|
||
| for (int i = 0; i < 9; i++) { | ||
| arr.add(Integer.valueOf(sc.nextInt())); | ||
| } | ||
|
|
||
| int max = Collections.max(arr); | ||
| int index = arr.indexOf(max); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 Collections를 응용해서 해결하고 싶었는데, 자꾸 오류가 나서 실패했었어요 |
||
|
|
||
| System.out.println(max); | ||
| System.out.println(index + 1); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적으로 저랑 똑같이 하셨네요!!!
저는 스캐너 대신 BufferedReader랑 StringTokenizer를 사용하였는데,
입출력시 속도 차이가 있어서, 나중엔 같은 구문이더라도, 스캐너를 사용하면
런타임 에러가 뜨는 경우가 있더라구요!!
이부분도 한 번 확인해보시면 좋을 것 같습니다!!