반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 자바 영어면접
- 자바 기술면접
- 백준 알고리즘
- 생활코딩
- react state
- 자바 개발자
- 아톰에디터
- 맥북 유용한 앱
- 자바 면접
- 알고리즘
- tech interview
- react jsx
- 맥북 팁
- Node.js Express
- 자바 인터뷰
- 백준
- 리액트
- mysql
- jsx 문법
- node.js
- 백준 단계별로 풀어보기
- React props
- React
- AtomEditor
- 맥북 필수 앱
- 맥북 초보
- 맥북 사용법
- 기술면접
- Express middleware
- Java tech interview
Archives
- Today
- Total
song.log
[Algorithm] 백준 단계별로 풀어보기 - 3.for문 본문
728x90
반응형
2741. N 찍기 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
for(int i = 1; i<=n; i++) {
System.out.println(i);
}
}
}
2439. 별 찍기-2 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제
하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오.
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
String star = "";
for (int i = 1; i <=n; i++) {
for(int j = n-i; j>0; j--) {
star +=" ";
}
for(int z=0; z<n-(n-i); z++) {
star +="*";
}
System.out.println(star);
star = "";
}
}
}
728x90
반응형
'StudyLog > Algorithm' 카테고리의 다른 글
[Algorithm] 백준 단계별로 풀어보기 - 5. 1차원 배열 (0) | 2019.12.21 |
---|---|
[Algorithm] 백준 단계별로 풀어보기 - 4.while문 (0) | 2019.12.20 |
[Algorithm] 백준 단계별로 풀어보기 - 2.if문 (0) | 2019.12.19 |
[Algorithm] 백준 단계별로 풀어보기 - 1.입/출력 받아보기 (0) | 2019.12.18 |
Comments