728x90 반응형 씨쁠쁠4 c++(cpp) 프로그래머스 : 코딩테스트 - 완주하지 못한 선수 #include #include #include using namespace std; string solution(vector participant, vector completion) { string answer = ""; sort(participant.begin(), participant.end()); sort(completion.begin(), completion.end()); for(int i = 0; i < participant.size();i++) { if(participant[i] != completion[i]) { answer = participant[i]; return answer; } } return participant[participant.size()-1]; } 2023. 1. 23. c++(cpp) 프로그래머스 - 코딩테스트 : k번째 수 #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; for(int i = 0 ; i < commands.size() ; i++) { vector temp; for(int j = commands[i][0]-1 ; j < commands[i][1]; j ++) { temp.push_back(array[j]); } sort(temp.begin(), temp.end()); answer.push_back(temp[commands[i][2]-1]); } return answer; } 2023. 1. 23. c++(cpp) 프로그래머스 - 코딩 테스트 : 부족한 금액 계산하기 using namespace std; long long solution(int price, int money, int count) { long long answer = 0; long long total_price=0; for(int i = 1 ; i = 0) return 0; return answer * -1; } 2022. 7. 31. c++(cpp) 프로그래머스 - 코딩 테스트 : 나머지가 1이 되는 수 찾기 #include #include using namespace std; int solution(int n) { int answer = 0; for(int i = 2 ; i < n;) { if(n%i == 1) { answer = i; break; } i++; } return answer; } 2022. 7. 31. 이전 1 다음 728x90 반응형