전체 글 (110) 썸네일형 리스트형 프로그래머스_0단계_인덱스 바꾸기 C++ #include #include using namespace std;string solution(string my_string, int num1, int num2) { string answer = ""; for(int i =0; i문제풀이: 프로그래머스_1단계_최대공약수와 최소공배수 C++ 문제풀이: #include #include using namespace std; vector solution(int n, int m) { vector answer; return answer; } #include #include using namespace std; int gcd(int a, int b) { while (b != 0) { int r = a % b; a = b; b = r; } return a; } int lcm(int a, int b) { return a * b / gcd(a, b); } vector solution(int n, int m) { vector answer; int greatest_common_divisor = gcd(n, m); int least_common_multiple .. 프로그래머스_1단계_콜라츠 추측 C++ 문제풀이: #include using namespace std; int solution(int num){ long long n = num; int answer = 0; while(true){ if(n==1) break; n%2 == 0 ? n/=2 : n = 3*n + 1; answer++; if(answer==500){ answer=-1; break; } } return answer; } 프로그래머스_1단계_약수의 합 C++ 문제풀이: 첫번째풀이는 n이클경우 비효율적일수있다 2번째방법으로 구해보자 #include #include using namespace std; int solution(int n) { int answer = 0; for(int i=1; i 프로그래머스_0단계_첫 번째로 나오는 음수 C++ 문제풀이: #include #include using namespace std; int solution(vector num_list) { int answer = -1; for(int i=0;i 프로그래머스_0단계_대문자와 소문자 C++ 문제풀이: #include #include #include using namespace std; string solution(string my_string) { string answer = ""; for(char c : my_string) { if(c>='A'&& c='a'&& c 프로그래머스_0단계_뒤에서 5등 위로 C++ 문제풀이: #include #include #include using namespace std; vector solution(vector num_list) { vector answer; // num_list에서 가장 작은 5개의 수를 제외한 수를 answer에 추가 for (int i = 0; i < num_list.size(); ++i) { answer.push_back(num_list[i]); } // 오름차순으로 정렬 sort(answer.begin(), answer.end()); for (int i = 0; i < 5; i++) { answer.erase(answer.begin()); } return answer; } 프로그래머스_0단계_소문자로 바꾸기 C++ 문제풀이: #include #include #include using namespace std; string solution(string myString) { string answer = ""; for(char c : myString) { answer+= tolower(c); } return answer; } 이전 1 2 3 4 5 ··· 14 다음