C언어/문제풀다 하나씩
흠 start = mid는 에러나는 군
mcdn
2020. 5. 23. 13:29
반응형
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string board;
int main() {
cin >> board;
// #####____
int len = 10;
if (board[0] == '_') {
cout << "0%";
}
else if (board[len - 1] == '#') {
cout << "100%";
}
else {
int start = 0;
int end = len - 1;
while (1) {
int mid = (start + end) / 2;
if (board[mid - 1] == '#' && board[mid] == '_') {
cout << mid << "0%";
break;
}
else if (board[mid - 1] == '#') {
start = mid+1;
}
else {
end = mid - 1;
}
}
}
}
start = mid라고 설정하니까
에러 뜸;;;
반응형