SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
문제 접근법 : 간단합니다. 문자를 2개로 잘라주고 그숫자가 12가 초과되거나 0인경우 YY가 될수있다는것만 알면 되기때문에 그에대한 예외 처리만 해주면 되는 문제였습니다.
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
32
33
34
|
//By 콩순이냉장고
#include <iostream> #include <string>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int testcase;
cin >> testcase;
for (int test = 1; test <= testcase; test++){
int n;
cin >> n;
int num1 = n / 100;
int num2 = n % 100;
bool flag1 = false;
bool flag2 = false;
cout << "#" << test << " ";
if (num1 > 12 || num1 == 0)
flag1 = true;
if (num2 > 12 || num2 == 0)
flag2 = true;
if (flag1&&flag2)
cout << "NA\n";
else if (flag1)
cout << "YYMM\n";
else if (flag2)
cout << "MMYY\n";
else
cout << "AMBIGUOUS\n";
}
}
|
cs |
궁금한점 혹은 모르는것이 있다면 언제든지 댓글을 이용해주시길 바랍니다.
'SWEA' 카테고리의 다른 글
[SWEA] 4013 특이한 자석 (모의 SW 역량테스트) (0) | 2020.09.27 |
---|---|
[SWEA] 9940 순열1 (0) | 2020.09.15 |
[SWEA] 7792 반장 선출 (0) | 2020.09.15 |
[SWEA] 4615 재미있는 오셀로 게임 (0) | 2020.09.15 |
[SWEA] 9708 가장 긴 수열 (0) | 2020.08.11 |