사생활 보호 설정
https://gamjia.tistory.com
Updated News
Mini Rooms
답글수 [0]
What Friends Say
한마디로 표현해봐~
1촌평 관리
2018 Kakao Blind Recruitment - [1차] 다트 게임
GamJia 2023. 3. 27. 09:06
코딩테스트 연습 - Level 1 - [1차] 다트 게임
https://programmers.co.kr/learn/courses/30/lessons/17682
#include <string> #include <cmath> using namespace std; int solution(string dartResult) { int answer = 0; int score[3]={0,},key=0; string num; for(int i=0;i<dartResult.size();i++) { if(isdigit(dartResult[i])) { num.push_back(dartResult[i]); } else { if(dartResult[i]=='S') { score[key++]=stoi(num); } else if(dartResult[i]=='D') { score[key++]=pow(stoi(num),2); } else if(dartResult[i]=='T') { score[key++]=pow(stoi(num),3); } else if(dartResult[i]=='*') { if(key-2>=0) { score[key-2]*=2; } score[key-1]*=2; } else if(dartResult[i]=='#') { score[key-1]*=-1; } num=""; } } for(int i=0;i<3;i++) { answer+=score[i]; } return answer; }