본문 바로가기

C++/코드트리

[코드트리 챌린지] 1주차 실력진단

 

실력진단을 풀다가 해시문제에서 막혔다. 

해시를 제대로 공부한 적이 없긴해서 그부분을 공부해봐야겠다고 생각했다.

 

https://www.codetree.ai/cote/13/problems/007?&utm_source=clipboard&utm_medium=text

 

코드트리 | 코딩테스트 준비를 위한 알고리즘 정석

국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요.

www.codetree.ai

 

그동안 c++ 문제를 풀때 구조체를 사용하여서 문제를 풀었는데 c++로 푸는 만큼 클래스를 활용해보려고 해야겠다. 물론 구조체를 써와서 구조체가 편하겠지만, 공부하는 동안에는 익숙해지도록 노력해봐야겠다.

#include <iostream>
using namespace std;
class Node {
    public:
        string secretCode;
        char meetingPoint;
        int time;
        Node(string secretCode, char meetingPoint, int time) {
            this->secretCode = secretCode;
            this->meetingPoint = meetingPoint;
            this->time = time;
        }
};

int main() {
    string secretCode;
    char point;
    int t;
    cin >> secretCode >> point >> t;
    Node node1 = Node(secretCode, point, t);
    cout << "secret code : " << node1.secretCode << '\n';
    cout << "meeting point : " << node1.meetingPoint << '\n';
    cout << "time : " << node1.time << '\n';
    return 0;
}