본문 바로가기
알고리즘 일기

템플릿 // char->string

by Beijing_KingGod 2019. 9. 2.
#include <string>
#include <vector>
#include <iostream>
using namespace std;

template <class T> 
void  print(vector<vector<T>> temp){
    for(int i=0; i<temp.size(); i++){
       for(int j=0; j<temp[i].size();j++){
        cout<<temp[i][j]<<" ";
       }cout<<endl;
    }
    cout<<endl;
}
template <class T>
void print(T s){
    cout<<s<<endl;
}
template <class T>
void print(vector<T> temp){
    for(int i=0; i<temp.size(); i++){
        cout<<temp[i]<<" ";
    }cout<<endl;
}

vector<int> make_vc(int n){
    vector<int> temp;
    for(int i=0; i<n; i++){
        temp.push_back(i);
    }
    return temp;
}
vector<string> make_vc(string s){
    vector<string> temp;
    for(int i=0; i<s.size(); i++){
        string s_temp;
        s_temp=s[i];
        temp.push_back(s_temp);
    }
    return temp;
}

vector<string> n_make_vc(string s){
    vector<string> temp;
    for(int i=0; i<s.size(); i++){
        string s_temp = to_string(s[i]-'0');
        temp.push_back(s_temp);
    }
    return temp;
}

int solution(vector<vector<int>> baseball) {
    int answer = 0;
    print(baseball);
    print("ddd");
    vector<string> vc= make_vc("string");
    print(vc);
    return answer;
}

'알고리즘 일기' 카테고리의 다른 글

프로그래머스 다음 큰 숫자 // 이진수 변환 // 시간초과됨(해결완료)  (0) 2019.09.03
행렬 경우의수  (0) 2019.09.02
조합  (0) 2019.09.02
전체 순열  (0) 2019.09.02
선택하는 순열  (0) 2019.09.02

댓글