본문 바로가기

c++86

[프로그래머스] 이어 붙인 수(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.
[프로그래머스] 조건 문자열(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181934 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(string ineq, string eq, int n, int m) { if(ineq==">"&&eq=="="&&n>=m||ineq==" 2023. 12. 27.
[프로그래머스] 홀짝에 따라 다른 값 반환하기(c++) https://school.programmers.co.kr/learn/courses/30/lessons/181935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 답 #include #include using namespace std; int solution(int n) { int ans=0; if(n%2!=0){ for(int i=1;i 2023. 12. 27.