728x90 반응형 SMALL 분류 전체보기161 [프로그래머스] 문자 반복 출력하기 #include #include using namespace std; string solution(string my_string, int n) { string answer = ""; for(auto s : my_string) for(int i=0;i answer.push_back(s); return answer; } 2025. 9. 4. [프로그래머스] 문자열안에 문자열 #include #include using namespace std; int solution(string str1, string str2) { int answer = 0; return str1.find(str2) != string::npos ? 1:2; } 2025. 9. 4. [프로그래머스] 아이스 아메리카노 #include #include using namespace std; vector solution(int money) { vector answer; answer.push_back(money/5500); answer.push_back(money%5500); return answer; } 2025. 9. 4. [프로그래머스] 배열 원소의 길이 #include #include using namespace std; vector solution(vector strlist) { vector answer; for(auto str : strlist) answer.push_back(str.length()); return answer; } 2025. 9. 4. [프로그래머스] n의 배수 고르기 #include #include using namespace std; vector solution(int n, vector numlist) { vector answer; for(auto num : numlist) { if(num%n==0) answer.push_back(num); } return answer; } 2025. 9. 4. [프로그래머스] 순서쌍의 개수 #include #include #include using namespace std; int solution(int n) { int answer = 0; vector nums1; // n의 약수들을 구해서 오름차순, 내림차순 각각 구하기 for(int i=1; i if(n%i==0) nums1.push_back(i); } return nums1.size(); } 2025. 9. 4. [프로그래머스] 배열의 유사도 #include #include using namespace std; int solution(vector s1, vector s2) { int answer = 0; for(auto one : s1) { for(auto two : s2) { if(one==two) answer++; } } return answer; } 2025. 9. 4. [프로그래머스] 점의 위치 구하기 #include #include using namespace std; int solution(vector dot) { bool x,y; x = dot[0]>0?1:0; y = dot[1]>0?1:0; if(x && y) return 1; else if(!x && y) return 2; else if(!x && !y) return 3; else if(x && !y) return 4; } 2025. 9. 4. [프로그래머스] 배열 자르기 #include #include using namespace std; vector solution(vector numbers, int num1, int num2) { vector answer; //numbers[num1]번째부터 numbers[num2]번째까지 for(int i=num1; i answer.push_back(numbers[i]); return answer; } 2025. 9. 3. 이전 1 2 3 4 5 6 ··· 18 다음 728x90 반응형 LIST