문제 링크입니다: www.acmicpc.net/problem/21355
21355번: Personnummer
Svenska personnummer skrivs oftast med tio siffror på formatet ÅÅMMDD-XXXX. De sex första siffrorna utgör personens födelsedatum, så en person med personnummer 781113-3285 är t.ex. född den 13:e november 1978. En detalj som många inte känner ti
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
string socialSecurityNumber; | |
cin >> socialSecurityNumber; | |
string result; | |
if (socialSecurityNumber.find('-') == string::npos) | |
{ | |
if (socialSecurityNumber.substr(0, 2) < "20") | |
{ | |
result = "19" + socialSecurityNumber; | |
} | |
else | |
{ | |
result = "18" + socialSecurityNumber; | |
} | |
} | |
else | |
{ | |
if (socialSecurityNumber.substr(0, 2) <= "20") | |
{ | |
result = "20" + socialSecurityNumber; | |
} | |
else | |
{ | |
result = "19" + socialSecurityNumber; | |
} | |
} | |
for (int i = 0; i < result.size(); i++) | |
{ | |
if (result[i] == '+' || result[i] == '-') | |
{ | |
continue; | |
} | |
cout << result[i]; | |
} | |
cout << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2863번 이게 분수? (0) | 2021.04.25 |
---|---|
백준 2783번 삼각 김밥 (0) | 2021.04.25 |
백준 21354번 Äpplen och päron (0) | 2021.04.25 |
백준 21591번 Laptop Sticker (0) | 2021.04.25 |
백준 2765번 자전거 속도 (0) | 2021.04.25 |