전체 글 203

프로그래머스 - 이상한 문자 만들기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12930 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; string solution(string s) { string answer = ""; int cnt = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == ' ') { cnt = 0; } else { if (cnt % 2 == 0) s[i] = (char)toupper..

프로그래머스 - 문자열 내림차순 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12917 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; bool compare(int a,int b) { if(a>b) return true; else return false; } string solution(string s) { sort(s.begin(),s.begin()+s.length(),compare); return s; } 설명 이 문제는 주어진 문자열을 내..

프로그래머스 - 같은 숫자는 싫어 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12906 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; vector solution(vector arr) { vector answer; int s=arr[0]; answer.push_back(s); for(int i=1;i

프로그래머스 - 직사각형 별찍기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12969 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include using namespace std; int main(void) { int a; int b; cin >> a >> b; for(int i=0;i

프로그래머스 - 문자열 다루기 기본 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12918 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; bool solution(string s) { bool answer = true; if(s.length()==4 || s.length()==6) { bool c = true; for(int i=0;i

프로그래머스 - 행렬의 덧셈 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12950 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; vector solution(vector arr1, vector arr2) { vector answer; int row = arr1.size(); int col=arr1[0].size(); for(int i=0;i

프로그래머스 - 부족한 금액 계산하기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/82612 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr using namespace std; long long solution(int price, int money, int count) { long long answer = money; for(int i=1;i0) return 0; else return answer*-1; } 설명 이 문제는 놀이기구를 count번탈 때의 총 비용보다 money가 작은지 큰지를 비교해서 크면 0을 작으면 얼만큼 작은지를..

프로그래머스 - 하샤드 수 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12947 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; bool solution(int x) { int n = 0; int ori = x; while(x>0) { n+=x%10; x/=10; } if(ori%n==0) return true; else return false; } 설명 주어진 x 가 하샤드 수인지를 구하는 문제이다. 하샤드 수란 모든 자릿수의 합으로 x가 나누어 떨어지..

프로그래머스 - 수박수박수박수박수박수? - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12922 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; string solution(int n) { string answer = ""; for(int i=1;i