전체 글
-
[프로그래머스] 문자열 내 마음대로 정렬하기 c++Coding Test/programmers 2023. 1. 26. 00:34
문제 설명 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 ["sun", "bed", "car"]이고 n이 1이면 각 단어의 인덱스 1의 문자 "u", "e", "a"로 strings를 정렬합니다. 제한 사항 strings는 길이 1 이상, 50이하인 배열입니다. strings의 원소는 소문자 알파벳으로 이루어져 있습니다. strings의 원소는 길이 1 이상, 100이하인 문자열입니다. 모든 strings의 원소의 길이는 n보다 큽니다. 인덱스 1의 문자가 같은 문자열이 여럿 일 경우, 사전순으로 앞선 문자열이 앞쪽에 위치합니다. 입출력 예 strings n return ["sun", "b..
-
[프로그래머스] 이모티콘 할인행사 c++Coding Test/programmers 2023. 1. 25. 15:00
문제 설명 카카오톡 사용자 n명의 구매 기준을 담은 2차원 정수 배열 users, 이모티콘 m개의 정가를 담은 1차원 정수 배열 emoticons가 주어집니다. 이때, 행사 목적을 최대한으로 달성했을 때의 이모티콘 플러스 서비스 가입 수와 이모티콘 매출액을 1차원 정수 배열에 담아 return 하도록 solution 함수를 완성해주세요. 제한 사항 1 ≤ users의 길이 = n ≤ 100 users의 원소는 [비율, 가격]의 형태입니다. users[i]는 i+1번 고객의 구매 기준을 의미합니다. 비율% 이상의 할인이 있는 이모티콘을 모두 구매한다는 의미입니다. 1 ≤ 비율 ≤ 40 가격이상의 돈을 이모티콘 구매에 사용한다면, 이모티콘 구매를 모두 취소하고 이모티콘 플러스 서비스에 가입한다는 의미입니다...
-
[프로그래머스] 시소 짝꿍 c++Coding Test/programmers 2023. 1. 25. 11:41
문제 설명 어느 공원 놀이터에는 시소가 하나 설치되어 있습니다. 이 시소는 중심으로부터 2(m), 3(m), 4(m) 거리의 지점에 좌석이 하나씩 있습니다. 이 시소를 두 명이 마주 보고 탄다고 할 때, 시소가 평형인 상태에서 각각에 의해 시소에 걸리는 토크의 크기가 서로 상쇄되어 완전한 균형을 이룰 수 있다면 그 두 사람을 시소 짝꿍이라고 합니다. 즉, 탑승한 사람의 무게와 시소 축과 좌석 간의 거리의 곱이 양쪽 다 같다면 시소 짝꿍이라고 할 수 있습니다. 사람들의 몸무게 목록 weights이 주어질 때, 시소 짝꿍이 몇 쌍 존재하는지 구하여 return 하도록 solution 함수를 완성해주세요. 제한 사항 2 ≤ weights의 길이 ≤ 100,000 100 ≤ weights[i] ≤ 1,000 몸..
-
[c++] basic_regex classProgramming/c++ 2023. 1. 20. 14:58
1. Parameter Elem The type of element to find a match for. RXtraits Traits class for elements. 2. Described 클래스 템플릿은 정규식을 보유하는 개체를 설명합니다. 이 클래스 템플릿의 개체는 템플릿 함수 regex_match, regex_search 및 regex_replace 전달할 수 있습니다. 또한 정규식과 일치하는 텍스트를 검색하기 위해 적절한 텍스트 문자열 인수를 전달합니다. 이 클래식 템플릿에는 char 타입 원소인 regex와 wchar_t 타입 원소인 wregex를 사용하는 두 개의 전문 클래스 템플릿이 있습니다. 3. Member member default public static const flag_typ..
-
[c++] regex swap 함수Programming/c++ 2023. 1. 20. 14:07
1.함수 헤더 파일 #include 2.함수 원형 template void swap( basic_regex& left, basic_regex& right) noexcept; template void swap( match_results& left, match_results& right) noexcept; 3. Parameter Elem The type of element to find a match for. RXtraits The attribute class for the element. 4. Described 템플릿 함수는 일정한 시간 내에 인수의 내용을 교환하고 예외를 발생시키지 않습니다. 4.예제 #include #include int main() { regex rx0("c(a*)|(b)"); reg..
-
[c++] regex_search 함수카테고리 없음 2023. 1. 20. 13:52
1.함수 헤더 파일 #include 2.함수 원형 template bool regex_search( BidIt first, Bidit last, match_results& match, const basic_regex& re, match_flag_type flags = match_default); template bool regex_search( BidIt first, Bidit last, const basic_regex& re, match_flag_type flags = match_default); template bool regex_search( const Elem* ptr, match_results& match, const basic_regex& re, match_flag_type flags = ma..
-
[c++] regex_replace 함수Programming/c++ 2023. 1. 20. 13:24
1.함수 헤더 파일 #include 2.함수 원형 template OutIt regex_replace( OutIt out, BidIt first, BidIt last, const basic_regex& re, const basic_string& fmt, match_flag_type flags = match_default); template basic_string regex_replace( const basic_string& str, const basic_regex& re, const basic_string& fmt, match_flag_type flags = match_default); 3. Parameter(매개 변수) OutIt The iterator type for replacement. BidIt..
-
[c++] regex_match 함수Programming/c++ 2023. 1. 20. 12:55
1.함수 헤더 파일 #include 2.함수 원형 regex_match : 정규식이 전체 대상 문자열과 일치하는지 여부를 테스트합니다. // (1) template bool regex_match( BidIt first, Bidit last, match_results& match, const basic_regex& re, match_flag_type flags = match_default); // (2) template bool regex_match( BidIt first, Bidit last, const basic_regex& re, match_flag_type flags = match_default); // (3) template bool regex_match( const Elem *ptr, match..