Vector를 입력받아 각각의 벡터 값들을 stringstream을 이용하여 공백을 기준으로 자르고 자른 값들로 Car클라스 객체의 멤버 변수를 만드는데 사용하였다.
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
using namespace std;
class Car
{
private:
string time;
string carNum;
string inNOut;
public:
Car(string theTime,string theCarNum,string theInNOut)
:time(theTime),carNum(theCarNum),inNOut(theInNOut)
{}
};
Car* carArr[10000];
/*
입력값은:
["05:31 1161 IN", "06:01 0000 IN", "06:31 0000 OUT", "07:01 1161 OUT", "07:49 0148 IN", "17:59 0000 IN", "18:09 0148 OUT", "21:59 1161 IN", "23:00 1161 OUT"]
*/
void solution(vector<int> fees, vector<string> records) {
int num=0;
for (auto& record : records) {
stringstream ss(record);
string a, b, c;
ss >> a >> b >> c;
carArr[num] = new Car(a,b,c);
}
}