GameStudy488 23-01-18 Ex) Level1 - 평균 구하기 accumulate() - numeric 헤더! #include #include #include using namespace std; double solution(vector arr) { double answer = 0; int iSum = accumulate(arr.begin(), arr.end(), 0); answer = iSum / (static_cast(arr.size())); return answer; } Ex) Level1 - 자릿수 더하기 #include using namespace std; int solution(int n) { int answer = 0; while (0 < n) { answer += n % 10; n /= 10; } return ans.. 2023. 1. 18. Chapter 04. 게임플레이 프레임워크 보호되어 있는 글 입니다. 2023. 1. 17. Chapter 03. 움직이는 액터의 제작 보호되어 있는 글 입니다. 2023. 1. 17. 23-01-17 Ex) Level0 - 특이한 정렬 sort() 함수에 익명함수를 넣어서 해결해보았다. 굉장히 신박했음. 익명함수로 Compare()를 만들 생각을 하자. #include #include #include using namespace std; vector solution(vector numlist, int n) { vector answer; sort(numlist.begin(), numlist.end(), [=](int a, int b){ if (abs(a - n) == abs(b - n)) { return a > b; } return abs(a - n) < abs(b - n); }); answer = numlist; return answer; } Ex) Level0 - 저주의 숫자 3[X] #includ.. 2023. 1. 17. 이전 1 ··· 35 36 37 38 39 40 41 ··· 122 다음