본문 바로가기

입문8

[C++/PGS] Lv.0 : 등수 매기기 https://school.programmers.co.kr/learn/courses/30/lessons/120882# 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr  프로그래머스 - 등수 매기기 문제 평균 연산 과정에서 나눗셈이 들어가는데소숫점까지 보고 순위를 구해야 해서int 대신 double로 평균을 구해야 한다!!!  나의 풀이#include #include #include #include #include using namespace std;vector solution(vector> score) { vector answer; vector avg; vector sorted_avg;.. 2025. 1. 13.
[PGS] Lv.0 (코딩테스트 입문) 6일차 문제 프로그래머스 문자열 뒤집기 string solution(string my_string) { string answer = ""; int len = my_string.length(); for(int i=1; i> n; for(int i=0; i 2023. 1. 16.
[PGS] Lv.0 (코딩테스트 입문) 5일차 문제 프로그래머스 옷가게 할인 받기 int solution(int price) { if(price >= 500000) price*=0.8; else if(price >= 300000) price*=0.9; else if(price >= 100000) price*=0.95; return (int)price; } 아이스 아메리카노 vector solution(int money) { vector answer; answer.push_back(money / 5500); answer.push_back(money % 5500); return answer; } 나이 출력 int solution(int age) { int answer = 2022+1-age; return answer; } 배열 뒤집기 vector soluti.. 2023. 1. 16.
[PGS] Lv.0 (코딩테스트 입문) 4일차 문제 프로그래머스 피자 나눠 먹기 (1) int solution(int n) { int answer = 0; for(int i=1; i= n) return i; } return answer; } 피자 나눠 먹기 (2) int solution(int n) { int answer = 0; for(int i=1; i 2023. 1. 16.
[PGS] Lv.0 (코딩테스트 입문) 3일차 문제 프로그래머스 나머지 구하기 int solution(int num1, int num2) { int answer = -1; answer = num1 % num2; return answer; } 중앙값 구하기 int solution(vector array) { int answer = 0; int len = array.size() + 1; sort(array.begin(), array.end()); answer = array[len / 2 - 1]; return answer; } 최빈값 구하기 ✍🏻 값을 구해야하는데 나온 횟수를 구하면서 삽질해서 좀 오래걸렸다,.. 일단 배열문제는 정렬부터 하고 시작하기!! ✍🏻 그리고 for문 1부터 시작할때는 항상 0인 예외를 고려해야 한다 int solution(vecto.. 2023. 1. 16.
[PGS] Lv.0 (코딩테스트 입문) 2일차 문제 프로그래머스 두 수의 나눗셈 // sol 1 int solution(int num1, int num2) { double answer = 0; double mod = 0; mod = modf((num1*1000)/num2, &answer); return (int)answer; } // sol 2 int solution(int num1, int num2) { double answer = (double)num1*1000/num2; return (int)answer; } 숫자 비교하기 int solution(int num1, int num2) { if(num1==num2) return 1; return -1; } 분수의 덧셈 vector solution(int denum1, int num1, int denum2.. 2023. 1. 16.
728x90
반응형