728x90 반응형 코딩 테스트3 c++(cpp) 프로그래머스 - 코딩 테스트 : 나누어 떨어지는 숫자 배열 #include #include #include using namespace std; vector solution(vector arr, int divisor) { vector answer; sort(arr.begin(), arr.end()); for(int i = 0; i < arr.size(); i++) { if(arr[i] % divisor == 0) { answer.push_back(arr[i]); } } if(answer.size() == 0) { answer.push_back(-1); } return answer; } 2022. 7. 31. c++(cpp) 프로그래머스 - 코딩 테스트 : 없는 숫자 더하기 #include #include using namespace std; int solution(vector numbers) { int answer = 0; for(int i = 0 ; i < numbers.size(); i ++) { for(int j = 0; j < 10; j++) { if(numbers[i] == j) { answer += j; } } } return 45 - answer; } 2022. 7. 28. c++(cpp) 프로그래머스 - 코딩 테스트 : 2016년 #include #include using namespace std; string solution(int a, int b) { string answer = ""; string week[7] = {"FRI", "SAT","SUN", "MON", "TUE", "WED", "THU"}; int month[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int sum=0; for(int i = 0; i < a; i++) { sum += month[i]; } sum += b-1; answer = week[sum%7]; return answer; } 2022. 7. 28. 이전 1 다음 728x90 반응형