#프로그래머스 #0단계 #C++ 32

프로그래머스 - 다항식 더하기 - C++

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

프로그래머스 - 연속된 수의 합 - C++

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

프로그래머스 - 유한소수 판별 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/120878 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; int solution(int a, int b) { int answer = 0; int coa = a; int cob = b; // 기약분수로 바꾸기 for (int i = a; i >= 2; i--) { if (coa % i == 0 && cob % i == 0) { coa /= i; cob /= i; } } bool ans..

프로그래머스 - 분수의 덧셈 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/120808 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; vector solution(int numer1, int denom1, int numer2, int denom2) { vector answer; // 분모 공배수 찾기 int cnt1 = denom1, cnt2 = denom2; for (int i = 0; denom1 != denom2; i++) { if (denom1 < d..

프로그래머스 - 삼각형의 완성 - C++

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

프로그래머스 - 평행 - C++

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

프로그래머스 - 안전지대 - C++

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

프로그래머스 - OX퀴즈 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/120907 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; bool Cal(int n1, int n2, int ans, char op) { switch (op) { case '+': return (n1 + n2 == ans) ? true : false; case '-': return (n1 - n2 == ans) ? true : false; case '*': return (n1 - n..

프로그래머스 - 특이한 정렬 - C++

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