코딩테스트 (71) 썸네일형 리스트형 프로그래머스_1단계_정수 제곱근 판별C++ 문제풀이: #include #include #include using namespace std; long long solution(long long n) { long long answer = 0; long long x = sqrt(n); // n이 x의 제곱이라면 (x+1)의 제곱을 반환, 아니라면 -1을 반환 if (n == x * x) answer = (x + 1) * (x + 1); else answer = -1; return answer; } 프로그래머스_1단계_ 직사각형 별찍기C++ 문제풀이: #include using namespace std; int main(void) { int a, b; cin >> a >> b; for (int j = 0; j < b; j++) { for (int i = 0; i < a; i++) { cout 프로그래머스_1단계_ 자릿수 더하기C++ 문제풀이: 깔끔하게풀어줍시다 #include using namespace std; int solution(int n) { int answer = 0; while(n>0) { answer+= n%10; n/=10; } return answer; } 프로그래머스_0단계_ 더 크게 합치기C++ 문제풀이: ** 잘풀었다 생각 문자열로 바꿔준후 이어붙이고 다시 형변환하여 크기비교하기 #include #include // max 함수를 사용하기 위한 헤더 using namespace std; int solution(int a, int b) { // 두 숫자를 문자열로 변환하여 이어붙인 값 중 더 큰 값을 반환 string a_str = to_string(a); string b_str = to_string(b); int ab = stoi(a_str + b_str); // a를 앞에, b를 뒤에 붙인 값 int ba = stoi(b_str + a_str); // b를 앞에, a를 뒤에 붙인 값 return max(ab, ba); } 프로그래머스_0단계_ A 강조하기C++ 문제풀이: #include #include using namespace std; string solution(string myString) { string answer = ""; for(char c: myString) { if( c == 'a') { c='A'; answer +=c; } else if( c> 'A') answer +=tolower(c); else answer +=c; } return answer; } 프로그래머스_0단계_ 공배수 C++ 문제풀이: #include #include using namespace std; int solution(int number, int n, int m) { int answer = 0; if(number%n==0 &&number%m==0) return answer = 1; else return answer = 0; } 프로그래머스_0단계_n 번째 원소부터 C++ 문제풀이: #include #include using namespace std; vector solution(vector num_list, int n) { vector answer; for(int i =n-1; i< num_list.size(); i++ ) { answer.push_back(num_list[i]); } return answer; } 프로그래머스_0단계_모음 제거 C++ 문제풀이: #include #include using namespace std; string solution(string my_string) { string answer = ""; for( char c : my_string) { if(c == 'a' || c == 'e' || c == 'i'|| c== 'o'|| c== 'u') continue; else { answer+= c; } } return answer; } 이전 1 2 3 4 5 6 7 8 9 다음