코딩테스트

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 접미사인지 확인하기

문제 코드 int solution(string my_string, string is_suffix) { int answer = 0; if (my_string.length() >= is_suffix.length()) { if (my_string.substr(my_string.length() - is_suffix.length()) == is_suffix) { return true; } } return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 접미사 배열

문제 코드 #include using namespace std; vector solution(string my_string) { vector answer; for(int i = 0; i

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 주사위 게임 3

문제 코드 int solution(int a, int b, int c, int d) { int answer = 0; vector numbers = { a,b,c,d }; sort(numbers.begin(), numbers.end()); if (numbers[0] == numbers[3]) { return 1111 * numbers[0]; } else if (numbers[0] == numbers[1] && numbers[2] == numbers[3]) { return (numbers[0] + numbers[2]) * abs(numbers[0] - numbers[2]); } else if (numbers[1] == numbers[2] && (numbers[0] == numbers[1] || numbers..

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 문자열 뒤집기

문제 코드 #include using namespace std; string solution(string my_string, int s, int e) { string answer = my_string; reverse(answer.begin() + s, answer.begin() + e + 1); return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 문자열 뒤의 n글자

문제 코드 #include #include using namespace std; string solution(string my_string, int n) { string answer = ""; answer = my_string.substr(my_string.size() - n); return answer; }

코딩테스트/프로그래머스(C++)_Level.0

[프로그래머스/C++] Lv.0 간단한 논리 연산

문제 코드 #include #include using namespace std; bool solution(bool x1, bool x2, bool x3, bool x4) { return (x1 || x2) && (x3 || x4); }

mane
'코딩테스트' 카테고리의 글 목록 (11 Page)