#프로그래머스 #1단계 #C++ 59

프로그래머스 - 제일 작은 수 지우기 - C++

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

프로그래머스 - 없는 숫자 더하기 - C++

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

프로그래머스 - 서울에서 김서방 찾기 - C++

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

프로그래머스 - 핸드폰 번호 가리기 - C++

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

프로그래머스 - 정수 내림차순으로 배치하기 - C++

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

프로그래머스 - 정수 제곱근 판별 - C++

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

프로그래머스 - 문자열 내 p와 y의 개수

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

프로그래머스 - 문자열을 정수로 바꾸기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12925 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; int solution(string s) { int answer = 0; if(s[0]=='-') { answer = stoi(s.substr(1)); answer*=-1; } else answer = stoi(s); return answer; } 설명 s 문자열의 숫자를 정수로 바꿔서 반환해주는 문제이다. stoi 함수를 이용..

프로그래머스 - 겹치는 선분의 길이 - C++

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