728x90
● [문제번호 1330] 두 수 비교하기
#include <stdio.h>
int main(void)
{
int a, b;
scanf("%d %d", &a, &b);
if(a < b)
printf("<");
else if(a > b)
printf(">");
else if(a == b)
printf("==");
return 0;
}
● [문제번호 9498] 시험 성적
#include <stdio.h>
int main(void)
{
int score;
scanf("%d", &score);
if(90 <= score && score <= 100)
printf("A");
else if(80 <= score)
printf("B");
else if(70 <= score)
printf("C");
else if(60 <= score)
printf("D");
else
printf("F");
return 0;
}
● [문제번호 2753] 윤년
#include <stdio.h>
int main(void)
{
int year;
scanf("%d", &year);
if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
printf("1");
else
printf("0");
return 0;
}
● [문제번호 14681] 사분면 고르기
#include <stdio.h>
int main(void)
{
int x, y;
scanf("%d", &x);
scanf("%d", &y);
if(x > 0 && y > 0)
printf("1");
else if(x < 0 && y > 0)
printf("2");
else if(x < 0 && y < 0)
printf("3");
else if(x > 0 && y < 0)
printf("4");
return 0;
}
// 중첩된 if문 쓰면 틀리는 것으로 간주
● [문제번호 2884] 알람 시계
#include <stdio.h>
int main(void)
{
int H, M;
scanf("%d %d", &H, &M);
if(M < 45)
{
H -= 1;
M = 60 + M - 45;
}
else
M -= 45;
if(H < 0)
H += 24;
printf("%d %d\n", H, M);
return 0;
}
728x90
'Baekjoon > 단계별로 풀어보기' 카테고리의 다른 글
[단계08] 기본 수학1 (9문제) (0) | 2020.12.20 |
---|---|
[단계07] 문자열 (10문제) (0) | 2020.12.20 |
[단계06] 함수 (3문제) (0) | 2020.12.18 |
[단계05] 1차원 배열 (7문제) (0) | 2020.12.17 |
[단계04] while문 (3문제) (0) | 2020.12.17 |
[단계03] for문 (11문제) (0) | 2020.12.17 |
[단계01] 입출력과 사칙연산 (11문제) (0) | 2020.12.16 |
댓글