-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from yjll1019/master
기초 알고리즘 io 추가문항 완료
- Loading branch information
Showing
7 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 16 | ||
*/ | ||
public class Code_10991 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("* "); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
System.out.println(sb2.substring(0,num-i)+sb.substring(0,2*i-1)); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 17 | ||
*/ | ||
public class Code_10992 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("**"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
if(i==1||i==num) { | ||
System.out.println(sb2.substring(0,num-i)+sb.substring(0,2*i-1)); | ||
} | ||
else { | ||
System.out.println(sb2.substring(0,num-i)+"*"+sb2.substring(0, 2*(i-1)-1)+"*"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 5 | ||
* 첫째 줄에는 별 1개, 둘째 줄에는 별 3개, ..., N번째 줄에는 별 2*N-1개를 찍는 문제(별은 가운데를 기준으로 대칭) | ||
*/ | ||
public class Code_2442 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("**"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
System.out.println(sb2.substring(0, num-i)+sb.substring(0, 2*i-1)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 7 | ||
*/ | ||
public class Code_2444 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
int num2 = num; | ||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("**"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
System.out.println(sb2.substring(0, num-i)+sb.substring(0, 2*i-1)); | ||
|
||
if(i==num) {//마지막까지 별을 찍고 역순으로 별을 찍기위해 while문 돌리기. | ||
int j=num-1; | ||
while(num2-->1) { | ||
System.out.println(sb2.substring(0, num-j)+sb.substring(0, 2*j-1)); | ||
j--; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 8 | ||
*/ | ||
public class Code_2445 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
int num2 = num; | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("*"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
System.out.println(sb.substring(0, i)+sb2.substring(0, 2*(num-i))+sb.substring(0, i)); | ||
if(i==num) {//마지막까지 별을 찍고 역순으로 별을 찍기위해 while문 돌리기. | ||
int j=i-1;//4부터시작 | ||
while(num2-->1) {//4부터시작 | ||
System.out.println(sb.substring(0, j)+sb2.substring(0, 2*(num-j))+sb.substring(0, j)); | ||
--j; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 9 | ||
* 첫째 줄부터 2*N-1번째 줄 까지 차례대로 별을 출력한다. | ||
*/ | ||
public class Code_2446 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
int num2 = num; | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("**"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=num; i>=1; --i) { | ||
System.out.println(sb2.substring(0, num-i)+sb.substring(0, 2*i-1)); | ||
//i가 감소할수록 공백은 커지고 별은 줄고 | ||
if(i==1) { | ||
for(int j=i+1; j<=num; ++j) { | ||
System.out.println(sb2.substring(0, num-j)+sb.substring(0, 2*j-1)); | ||
//j가 증가할수록 공백은 줄고 별은 커지고 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io; | ||
|
||
import java.util.Scanner; | ||
|
||
/* | ||
* 작성일 : 2018년 07월 23일 | ||
* 내 용 : 별찍기 - 12 | ||
* 첫째 줄부터 2*N-1번째 줄 까지 차례대로 별을 출력한다. | ||
*/ | ||
public class Code_2522 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
Scanner sc = new Scanner(System.in); | ||
|
||
int num = sc.nextInt(); | ||
int num2 = num; | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
StringBuilder sb2 = new StringBuilder(); | ||
|
||
for(int i=1; i<=num; ++i) { | ||
sb.append("*"); | ||
sb2.append(" "); | ||
} | ||
|
||
for(int i=1; i<=num; ++i) { | ||
System.out.println(sb2.substring(0,num-i)+sb.substring(0,i)); | ||
if(i==num) { //i==3 | ||
int j=i-1; | ||
while(num2-->1) { | ||
System.out.println(sb2.substring(0,num-j)+sb.substring(0,j)); | ||
--j; | ||
} | ||
} | ||
} | ||
} | ||
} |