백준 C++ 1213번 팰린드롬만들기 1213번 팰린드롬 만들기 문제풀이 #include #include #include using namespace std; int alpha[97]; string hol, zzac; int main() { string s; cin >> s; for (char i : s) { alpha[i]++; } for (char i = 'A'; i 1) { printf("I'm Sorry Hansoo"); } else { cout 자라는 개발자/문제풀이 2021.12.08
백준 c++ 10845번 큐 10845번 큐 문제풀이 #include #include #include using namespace std; queue q; void front() { if (!q.empty()) { printf("%d\n", q.front()); } else { cout 자라는 개발자/문제풀이 2021.12.07
백준 C++ 2164번 카드2 2164번 카드2 문제풀이 #include #include using namespace std; int main(void) { queue q; int input; cin >> input; for (int i = 0; i < input; i++) { q.push(i + 1); } while (input != 1) { q.pop(); q.push(q.front()); q.pop(); input--; } cout 자라는 개발자/문제풀이 2021.12.06
백준 C 1259번 팰린드롬수 1259번 팰린드롬수 문제 문제풀이 #include #include #include int main(void) { while (true) { bool ck = true; char num[10]; scanf("%s", &num); if (num[0] == '0') { break; } int len = strlen(num); for (int i = 0; i < len / 2; i++) { if (num[i] != num[len - 1 - i]) { ck = false; } } if (ck) { printf("yes\n"); } else { printf("no\n"); } } } 중간부터 yes가 no로 나오는 문제가 있었는데, ck를 선언한 위치가 while 반복문 바깥이어서 생긴 오류였다. 자라는 개발자/문제풀이 2021.12.03
백준 C++ 4949번 균형잡힌 세상 4949번 균형잡힌 세상 문제 풀이 #include #include #include using namespace std; int main(void) { while (1) { string str; getline(cin, str); if (str == ".") { break; } stack st; int ck = 0; for (int i = 0; i < str.length(); i++) { if (str[i] == 40 || str[i] == 91) { st.push(str[i]); } else if (str[i] == 41) { if (!st.empty() && st.top() == 40) { st.pop(); } else { ck = 1; } } else if (str[i] == 93) { if (!st.. 자라는 개발자/문제풀이 2021.12.01
백준 C 2775번 부녀회장이 될테야 2775번 부녀회장이 될테야 문제풀이 #include #include int main(void) { int testNum; int arr[15][15] = {0}; int k, n; for (int i = 0; i < 15; i++) { arr[0][i] = i + 1; arr[i][0] = 1; } for (int i = 1; i < 15; i++) { for (int j = 1; j < 15; j++) { arr[i][j] = arr[i - 1][j] + arr[i][j - 1]; } } scanf("%d", &testNum); for (int i = 0; i < testNum; i++) { scanf("%d\n%d", &k, &n); printf("%d\n", arr[k][n - 1]); } } 커.. 자라는 개발자/문제풀이 2021.11.30
백준 C++ 10814번 나이순정렬 10814 나이순 정렬 문제풀이 #include #include #include #include using namespace std; bool compare(pair a, pair b) { return a.first > n; for (int i = 0; i > age >> name; v.push_back(make_pair(age, name)); } stable_sort(v.begin(), v.end(), compare); for (int i = 0; i < n; i++) { printf("%d %s\n", v[i].first.. 자라는 개발자/문제풀이 2021.11.30
백준 C 23739번 벼락치기 백준 23739번 벼락치기 문제 풀이 C언어 #include int main(void) { int n; int sum = 0, cnt = 0; int arr[101] = {0}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); if ((arr[i] + 1) / 2 = 30) { sum = 0; } } printf("%d", cnt); } 예제입력 1에서는 문제없이 되는걸 확인했는데 , 2 에서 오류가 났다. 확인해보니 홀수와 짝수의 결과값이 같은걸 체크하지 않았고 +1 을 함으로써 구분을 해주었다. 자라는 개발자/문제풀이 2021.11.29