yooniiverse
개발 블로그
yooniiverse
전체 방문자
오늘
어제
  • 분류 전체보기
    • 운영체제
    • 네트워크
    • ~2023.02
      • 외부교육
      • 대외활동
      • 스터디
      • 동아리
      • TIL
      • IT지식
      • 기타
      • 트러블 슈팅
      • 프로그래밍
      • Python
      • Java
      • JS
      • DB(SQL)
      • JSP
      • Spring
      • 기술면접
      • 자바
      • 코딩테스트
      • 자료구조
      • 알고리즘
      • 백준 문제풀이
      • 인공지능
      • 머신러닝
      • 프로젝트
      • 안드로이드 앱개발
      • 웹개발
      • 웹 서비스
      • 웹퍼블리싱
      • Node.js 백엔드 개발
      • CS
      • 1일 1CS지식
      • 운영체제
      • 네트워크
      • 데이터베이스
      • 정보처리기사
      • 도서 리뷰
      • 개발 관련 도서
      • 기타 도서

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
yooniiverse

개발 블로그

~2023.02/백준 문제풀이

[JAVA] 백준 단계별로 풀어보기_3단계(for문)

2022. 2. 8. 23:14

2739번: 구구단

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();

        for (int i = 1; i < 10; i++) {
            System.out.println(num + " * " + i + " = " + num * i);
        };
    }
}

10950번: A+B-3

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();

        for (int i = 0; i < num ; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }
    }
}

8393번: 합

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int sum = 0;

        for (int i = 0; i <= n ; i++) {
            sum = sum + i;
            if (i == n) {
                System.out.println(sum);
            }
        }
    }
}

2741번: N찍기

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++) {
            System.out.println(i);
        }
    }
}

2742번: 기찍N

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++) {
            System.out.println((n + 1) - i);
        }
    }
}

11021번: A+B-7

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++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println("Case #" + i + ": " + (a + b));
        }
    }
}

11022번: A+B-8

import  java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int T = sc.nextInt();

        for (int i = 1; i <= T; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println("Case #" + i + ": " + a + " + " + b + " = " + (a + b));
        }
    }
}

2438번: 별 찍기-1

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        sc.close();

        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

2439번: 별 찍기-2

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        sc.close();

        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();
        }
    }
}

10871번: X보다 작은 수

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();

        StringBuilder sb = new StringBuilder();

        for (int i = 1; i <= N; i++) {
            int A = sc.nextInt();

            if (A < X) {
                sb.append(A + " ");
            }
        }
        System.out.print(sb);
    }
}

 

'~2023.02 > 백준 문제풀이' 카테고리의 다른 글

[JAVA] 백준 단계별로 풀어보기_5단계(1차원 배열)  (0) 2022.02.11
[JAVA] 백준 단계별로 풀어보기_4단계(while문)  (0) 2022.02.08
[JAVA] 백준 단계별로 풀어보기_3단계(for문)  (0) 2022.01.31
[JAVA] 백준 단계별로 풀어보기_2단계(if문)  (0) 2022.01.30
[JAVA] 백준 단계별로 풀어보기_1단계(입출력과 사칙연산)  (0) 2022.01.26
    '~2023.02/백준 문제풀이' 카테고리의 다른 글
    • [JAVA] 백준 단계별로 풀어보기_5단계(1차원 배열)
    • [JAVA] 백준 단계별로 풀어보기_4단계(while문)
    • [JAVA] 백준 단계별로 풀어보기_3단계(for문)
    • [JAVA] 백준 단계별로 풀어보기_2단계(if문)
    yooniiverse
    yooniiverse

    티스토리툴바