코딩테스트/프로그래머스 - LV 0
[프로그래머스] 이어 붙인 수
웅드
2024. 1. 24. 15:52
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(vector<int> num_list) {
string n_o;
string n_e;
for(int i=0; i<num_list.size(); i++){
if(num_list[i] % 2 == 0) n_o += to_string(num_list[i]);
else n_e += to_string(num_list[i]);
}
return stoi(n_o) + stoi(n_e);
}
반응형