Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 수광 소자
- 아두이노 소스
- Array
- 아두이노
- 운영체제
- arduino compiler
- stl
- Algorithm
- 통계학
- directx
- Visual Micro
- Arduino
- queue
- 아두이노 컴파일러
- C언어
- c++
- LineTracer
- html
- 라인트레이서
- map
- list
- set
- WinAPI
- vector
- Deque
- 시스템프로그래밍
- 컴퓨터 그래픽스
- priority_queue
- 자료구조
- Stack
Archives
- Today
- Total
Kim's Programming
1948. 날짜 계산기 본문
1948. 날짜 계산기
풀이 방법
<코드>
#include<iostream> using namespace std; int MonthDay(int month) { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; case 4: case 6: case 9: case 11: return 30; case 2: return 28; } } int main(int argc, char** argv) { int test_case; int T; cin >> T; for (test_case = 1; test_case <= T; ++test_case) { int month1{}, day1{}, month2{}, day2{}; int result{ 0 }; std::cin >> month1 >> day1 >> month2 >> day2; if (month1 == month2) result = day2 - day1 + 1; else { result = MonthDay(month1) - day1 + 1; for (int i = month1 + 1; i < month2; i++) result += MonthDay(i); result += day2; } std::cout << "#" << test_case << " "<<result << "\n"; } return 0;//정상종료시 반드시 0을 리턴해야합니다. }
'SW ExpertAcademy > D2' 카테고리의 다른 글
1959. 두 개의 숫자열 (0) | 2018.12.01 |
---|---|
1954. 달팽이 숫자 (0) | 2018.12.01 |
1946. 간단한 압축 풀기 (0) | 2018.12.01 |
1945. 간단한 소인수분해 (0) | 2018.12.01 |
1940. 가랏! RC카! (0) | 2018.12.01 |