[프로그래머스] 비밀지도

0

프로그래머스

목록 보기
13/128
post-thumbnail
post-custom-banner

[프로그래머스] 비밀지도

#include <string>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

vector<string> solution(int n, vector<int> arr1, vector<int> arr2) {
	
	vector<string> answer;
	
	for (int i = 0; i < n; ++i) {
		
		int num = arr1[i] | arr2[i];
		
		string row = "";
		while (num > 0) {
			if (num % 2) row += "#";
			else row += " ";
			num /= 2;
		}
		while (row.length() < n) {
			row += " ";
		}

		reverse(row.begin(), row.end());
		answer.push_back(row);
	}

	return answer;
}
profile
Be able to be vulnerable, in search of truth
post-custom-banner

0개의 댓글