알고리즘
백준 10769번: 행복한지 슬픈지
mezo
2020. 2. 8. 20:34
728x90
반응형
실수로 cin으로 해놓고 잘못된 걸 찾았던 문제..^^
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
string str;
int happy = 0;
int sad = 0;
getline(cin, str);
for (int i = 0; i < str.size(); i++) {
if (i < str.size()-3 && str[i] == ':'&& str[i + 1] == '-'&& str[i + 2] == ')') {
happy++;
}
else if (i < str.size() - 3 && str[i] == ':'&& str[i + 1] == '-'&& str[i + 2] == '(') {
sad++;
}
}
if (!happy && !sad)
cout << "none";
else if (happy == sad)
cout << "unsure";
else if (happy > sad)
cout << "happy";
else
cout << "sad";
return 0;
}
728x90
반응형