2026. 3. 19. 23:40ㆍ언리얼 7기 본캠프
//방금그곡 문제. 스트링을 자르고 주무르고 하는걸 굉장히 많이 하게 되는 문제
//struct를 이용해서 무언가 시도해보는건 처음이긴 했고, 이게 사실 메모리 효율이 어쩌고 하지만
//아직 거기까지 생각이 닿지는 않는 것 같다
#include <string>
#include <vector>
#include <cctype>
using namespace std;
struct musicrecord
{
int duration;
string songname;
string totalnotes;
};
string convertnotes(const string& s){
if (s.length() <= 1) return s;
string str = "";
for(int i = 0; i < s.length() ; i++)
{
if (s[i] == '#')
{
str.back() = tolower(str.back());
}
else str += s[i];
}
return str;
}
string solution(string m, vector<string> musicinfos) {
string answer = "(None)";
string tofind = convertnotes(m);
vector<musicrecord> musics;
for(const string& s : musicinfos)
{
string starttime = "", endtime = "", name = "", notes = "";
int phase = 0;
for(char c : s)
{
if (c == ',') phase++;
else
{
switch(phase)
{
case 0:
if (c != ':') starttime += c;
break;
case 1:
if (c != ':') endtime += c;
break;
case 2:
name += c;
break;
case 3:
notes += c;
break;
}
}
}
int startint = (stoi(starttime) / 100 * 60) + (stoi(starttime) % 100);
int endint = (stoi(endtime) / 100 * 60) + (stoi(endtime) % 100);
int totalduration = endint - startint;
string convertednotes = convertnotes(notes);
string totalnotes = "";
for(int i = 0; i < totalduration; i++)
{
totalnotes += convertednotes[i % convertednotes.length()];
}
musicrecord newmusic;
newmusic.duration = totalduration;
newmusic.songname = name;
newmusic.totalnotes = totalnotes;
musics.push_back(newmusic);
}
int maxduration = -1;
for (const auto& m : musics)
{
if (m.totalnotes.find(tofind) != string::npos)
{
if (m.duration > maxduration)
{
maxduration = m.duration;
answer = m.songname;
}
}
}
return answer;
}
심화반 CS 질문 : Java나 Unreal에는 있는 Garbage Collector가 일반 C++에서 없는 이유를 게임에서 GC의 단점과 엮어서 설명
배운 내용:
GC는 실행할 타이밍을 조절할 수 없고, 필연적으로 작동시 렉을 동반하며, GC의 지속적인 추적때문에 추가적인 메모리가 소모된다는 단점이 있음
C++에서는 RAII를 통한 생명주기 및 스마트 포인터 등 다양한 수단을 사용하여 개발자가 직접 메모리를 정밀하게 조정하게끔 만들어서 GC를 사용하지 않고도 메모리를 관리하게 만듬
그동안 과제에 너무 몰입해서 하느라 TIL을 날림(...)으로 적어버린 문제가 있었는데 앞으로는 과제가 바쁘더라도 TIL을 꼬박꼬박 적어서 활동을 기록해 나가려고 함
이번에도 과제 마개조를 하는 바람에 필요 이상의 손이 과하게 들어버렸지만, UI를 제외하면 작동 자체는 만족스럽게 되기 때문에 아주 좋음
동작하면서 있었던 버그들 :
게임이 완료된 후 재시작이 불가능함 -> 게임 완료 처리를 서버에서만 하고 각 클라로 보내지 않아서 클라의 상태 초기화가 이루어지지 않아 재시작이 안됨. 종료 시 신호를 확실하게 보내 클라에서 초기화를 처리하고 다시 시작 가능하게 만듬
wordle 단어를 입력해도 유효 단어 처리가 안됨 -> 첨부한 json이 wordle 정답 / wordle 입력가능 단어 로 나뉘어있었는데, '유효 단어' 처리 배열은 정답 + 입력가능 단어 를 합쳐서 만들어야 처리가 가능한데 입력가능 단어만 넣어서 유효처리를 했기때문에 되지 않는 것이었음. json 로드시 배열에 정보 넣는것을 수정하는것으로 해결
과제 시연 영상 및 리포지토리는 하단에 첨부함
https://github.com/Nichipe-JCM/CPP_Assignment_9_JCM
GitHub - Nichipe-JCM/CPP_Assignment_9_JCM: 내배캠 언리얼 C++ 9번과제
내배캠 언리얼 C++ 9번과제. Contribute to Nichipe-JCM/CPP_Assignment_9_JCM development by creating an account on GitHub.
github.com
'언리얼 7기 본캠프' 카테고리의 다른 글
| 260323 TIL - 챕터4 멀티플레이어 게임개발 11일차 (0) | 2026.03.23 |
|---|---|
| 260320 TIL - 챕터4 멀티플레이어 게임 개발 10일차 (0) | 2026.03.20 |
| 260318 TIL - 챕터4 멀티플레이어 게임 개발 8일차 (0) | 2026.03.18 |
| 260317 TIL - 챕터4 멀티플레이어 게임 개발 7일차 (0) | 2026.03.17 |
| 260313 TIL - 챕터4 멀티플레이어 게임 개발 5일차 (1) | 2026.03.13 |