백준 단계별로 풀어보기 3단계 [반복문]
- 단계 : 3-1
- 문제 : #2739
- 문제 제목 : 구구단
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.close();
for ( int i=1; i< 10; i++){
System.out.println( n +" * " + i + " = " + n*i);
}
}
}
- 단계 : 3-2
- 문제 : #10950
- 문제 제목 : A+B - 3
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner( System.in);
int t = in.nextInt();
for (int i =0; i < t ; i++){
int a = in.nextInt();
int b = in.nextInt();
System.out.println(a+b);
}
in.close();
}
}
- 단계 : 3-3
- 문제 : #8393
- 문제 제목 : 합
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.close();
int sum = 0;
for ( int i =1 ; i <= n; i ++){
sum += i;
}
System.out.println( sum );
}
}
- 단계 : 3-4
- 문제 : #25304
- 문제 제목 : 영수증
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int total = in.nextInt();
int n = in.nextInt();
int sum = 0;
for ( int i=0; i < n; i ++){
int money = in.nextInt();
int any = in.nextInt();
sum += money * any;
}
in.close();
if( total == sum){
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
- 단계 : 3-5
- 문제 : #25314
- 문제 제목 : 코딩은 체육과목 입니다
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = "";
int n = in.nextInt();
in.close();
int cnt = n/4;
for (int i =0; i < cnt; i++){
str += "long ";
}
System.out.println(str + "int");
}
}
- 단계 : 3-6
- 문제 : #15552
- 문제 제목 : 빠른 A+B
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(br.readLine());
StringTokenizer st;
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine()," ");
bw.write((Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()))+ "\n");
}
br.close();
bw.flush();
bw.close();
}
}
- 단계 : 3-7
- 문제 : #11021
- 문제 제목 : A+B - 7
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for ( int i = 1; i<= n; i++){
int a = in.nextInt();
int b = in.nextInt();
System.out.println("Case #"+i+": "+ (a+b));
}
in.close();
}
}
- 단계 : 3-8
- 문제 : #11022
- 문제 제목 : A+B - 8
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for ( int i = 1; i<= n; i++){
int a = in.nextInt();
int b = in.nextInt();
System.out.println("Case #"+i+": "+a+" + " + b +" = "+ (a+b));
}
in.close();
}
}
- 단계 : 3-9
- 문제 : #2438
- 문제 제목 : 별 찍기 - 1
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String str = "";
for ( int i = 1; i<= n; i++){
for ( int j = 1; j <= n-i; j++){
System.out.print(" ");
}
for ( int k = 1; k <= i; k++){
System.out.print("*");
}
System.out.println();
}
in.close();
}
}
- 단계 : 3-10
- 문제 : #10951
- 문제 제목 : A+B - 4
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNextInt()){
int a = in.nextInt();
int b = in.nextInt();
System.out.println(a+b);
}
in.close();
}
}