[algorithm] 백준 10871번 x보다 작은수

2025. 10. 10. 19:21·algorithm/기초 코드
반응형

 

 

풀이 : 이 문제는 두 수 n과 x를 입력받고 for문을 돌면서 입력받는 a 값이 x보다 작으면 출력하도록

          설정하면 되는 문제이다. 배열을 만들어서 풀 수도 있는데 비효율적인 것 같아 아래와 같이 풀이했다.

 

코드

#include <iostream>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,x,a;
    cin >> n >> x;
    for (int tmp = 0; tmp < n; tmp++)
        {
            cin >> a;
            if (a < x)
            {
                cout << a << " ";
            }
        }
    
    return 0;
}

 

반응형

'algorithm > 기초 코드' 카테고리의 다른 글

[algorithm] 백준 9498번 시험 성적  (0) 2025.10.12
[algorithm] 백준 10869번 사칙연산  (0) 2025.10.10
[algorithm] 백준 10171번 고양이  (0) 2025.10.10
[algorithm] 백준 2557번 Hello World  (0) 2025.10.10
[algorithm] 백준 1000번 A+B  (0) 2025.10.10
'algorithm/기초 코드' 카테고리의 다른 글
  • [algorithm] 백준 10869번 사칙연산
  • [algorithm] 백준 10171번 고양이
  • [algorithm] 백준 2557번 Hello World
  • [algorithm] 백준 1000번 A+B
20puddle
20puddle
20puddle 님의 블로그 입니다.
  • 20puddle
    20puddle 님의 블로그
    20puddle
  • 전체
    오늘
    어제
    • 분류 전체보기 (100)
      • Spring boot (5)
      • git & github (5)
      • algorithm (47)
        • theory (3)
        • 배열 (7)
        • 연결 리스트 (3)
        • 스택 (5)
        • 큐 (3)
        • 덱 (2)
        • 기초 코드 (19)
        • BFS (5)
      • AI (43)
        • Machine Learning (35)
        • Deep Learning (8)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    ML
    주성분변환
    AI
    오프라인 학습
    DL
    github
    게시판
    알고리즘
    Spring Boot
    백준
    그레디언트 클리핑
    머신러닝
    홀드아웃 검증
    list
    git
    인공지능
    연결리스트
    Java
    Aimers
    딥러닝
  • 최근 댓글

  • 최근 글

  • 반응형
  • hELLO· Designed By정상우.v4.10.3
20puddle
[algorithm] 백준 10871번 x보다 작은수
상단으로

티스토리툴바