분류 전체보기245 [프로그래머스] 문자열 정수의 합(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181849 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(string num_str) { int answer = 0; for(int i=0;i 2023. 12. 27. [프로그래머스] 문자열의 뒤의 n글자(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181910 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; string solution(string my_string, int n) { string answer; answer+=my_string.substr(my_string.size()-n,my_string.size()); return answer; } string answer을 만들어준다. substr을 사용해서 my_strin.. 2023. 12. 27. [프로그래머스] 이어 붙인 수(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181928 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(vector num_list) { string ans1,ans2; for(int i=0;i 2023. 12. 27. [프로그래머스] 수 조작하기1(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181926 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include using namespace std; int solution(int n, string control) { for(int i=0;i 2023. 12. 27. [프로그래머스] 마지막 두 원소(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181927 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; vector solution(vector num_list) { int a=num_list[num_list.size()-1]; int b=num_list[num_list.size()-2]; if(a>b){ num_list.push_back(a-b); } else{ num_list.push_back(a*2); } return .. 2023. 12. 27. [프로그래머스] flag에 따라 다른 값 반환하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181933 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(int a, int b, bool flag) { if(flag==true){ return a+b; } else{ return a-b; } } flag가 true인지 판단하고 그에 따라서 출력해준다. true이면 a+b 아니면 a-b 참고로 if(flag){ return a+b; } if문을 이.. 2023. 12. 27. 이전 1 ··· 27 28 29 30 31 32 33 ··· 41 다음