본문 바로가기

프로그래밍/코딩 문제 풀이76

프로그래머스 2023.06.13 (1Lv 정수 내림차순으로 배치하기) 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 코딩 #include #include #include using namespace std; long long solution(long long n) { long long answer = 0; string num = to_string(n); sort(num.begin(), num.end(), greater()); answer = stoll(num); return answer; } n을 string으로 전환한 이유는 n의 자릿수를 알아내기 위함이었다. (length()함수를 이용해 자릿수를 알아낸 뒤, 직접.. 2023. 6. 19.
프로그래머스 2023.06.12 (1Lv 직사각형 별찍기 / 핸드폰 번호 가리기) 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 (직사각형 별찍기) 코딩 #include int main(void) { int a; int b; scanf("%d %d", &a, &b); for(int i = 0; i < b; ++i) { for(int j = 0; j < a; ++j) { printf("*"); } printf("\n"); } return 0; } 실행 결과 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. progra.. 2023. 6. 19.
프로그래머스 2023.06.11 (2Lv 프로세스) 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 코딩 #include #include #include using namespace std; struct tNode { int iPriorities; int iLocation; }; int solution(vector priorities, int location) { int answer = 0; int iTarget = 0; int iNextTarget = 0; int iCount = 0; queue qwait = {}; for (size_t i = 0; i < priorities.size(); ++i) .. 2023. 6. 19.
프로그래머스 2023.06.09 (2Lv 기능개발) 문제코딩#include #include #include using namespace std;vector solution(vector progresses, vector speeds) { vector answer; int imaxday = 0; for (size_t i = 0; i 더보기Notefloat에서 int를 강제 케스팅 하면, 소수점을 제외한 정수형으로 출력된다. 즉, 5.2 → 5, 5.8 → 5로 된다.올림 함수 ceil()은 cmath 라이브러리를 참조해야 한다.vector의 멤버함수 vector.back()은 가장 마지막 원소를 참조한다. 2024.04.24원래 코드는 11번 케이스가 통과하지 못했는데,iday = (int)ceil((100 - .. 2023. 6. 19.