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
- 시스템프로그래밍
- stl
- Stack
- Algorithm
- Arduino
- c++
- vector
- C언어
- 컴퓨터 그래픽스
- html
- arduino compiler
- 통계학
- queue
- WinAPI
- LineTracer
- 아두이노
- 수광 소자
- 자료구조
- 라인트레이서
- priority_queue
- 운영체제
- 아두이노 컴파일러
- map
- Deque
- set
- directx
- Array
- Visual Micro
- list
- 아두이노 소스
Archives
- Today
- Total
Kim's Programming
2056. 연월일 달력 본문
2056. 연월일 달력
풀이 방법
<코드>
#include <iostream> int main() { int n{0}; std::cin>>n; for(int testCase =1 ; testCase<=n ; testCase++) { int input{0}; bool isValid = true; std::cin>>input; int year = input / 10000; input = input - (year * 10000); int month = input / 100; input = input%100; if(month <1 || month >12) isValid =false; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if(input>31 || input<1) isValid = false; break; case 4: case 6: case 9: case 11: if(input>30 || input<1) isValid = false; break; case 2: if(input>28 || input<1) isValid = false; break; } std::cout<<"#"<<testCase<<" "; if(isValid) { if(year<1000) { std::cout.width(4); std::cout.fill('0'); } std::cout<<year<<'/'; std::cout.width(2); std::cout.fill('0'); std::cout<<month<<'/'; std::cout.width(2); std::cout.fill('0'); std::cout<<input<<"\n"; } else std::cout<<-1<<"\n"; } return 0; }
'SW ExpertAcademy > D1' 카테고리의 다른 글
2063. 중간값 찾기 (0) | 2018.11.30 |
---|---|
2058. 자릿수 더하기 (0) | 2018.11.30 |
2050. 알파벳을 숫자로 변환 (0) | 2018.11.30 |
2047. 신문 헤드라인 (0) | 2018.11.30 |
2046. 스탬프 찍기 (0) | 2018.11.30 |