반응형
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 | 29 | 30 | 31 |
Tags
- Game Engine Architecture
- Structure and Interpretation of Computer Programs
- keras
- 컴퓨터그래픽스
- Kotaro Oshio - twilight short version
- MNIST
- 오픈소스
- Arevia
- Computer Graphics
- Revolution OS
- DirectXOpenTutorial
- fsf
Archives
- Today
- Total
kimkijun
[백준 2884번] 알람 시계 [C++] 본문
[문제 방식]
https://www.acmicpc.net/problem/2884
2884번: 알람 시계
상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다. 상근이는 모든 방법을 동원해보았지만,
www.acmicpc.net
[풀이 과정]
m 이 45분 보다 작을 경우 15분을 더하고 1시간을 빼줌.
m 이 45분 보다 크거나 같을 경우 45분을 빼줌.
간단한건데 헷갈림...ㅠ
[소스 코드]
#include <iostream>
using namespace std;
int main()
{
int h, m;
cin >> h >> m;
if( m < 45){
m += 15;
h -= 1;
if( h < 0 ) h = 23;
}else{
m -=45;
}
cout << h <<' '<< m;
}
반응형
'알고리즘' 카테고리의 다른 글
[백준 2753번] 윤년 [C++] (0) | 2021.12.15 |
---|---|
[백준 2588번] 곱셈 [C++] (0) | 2021.12.15 |
[백준 1008번] A/B - [C++] (0) | 2021.12.15 |