![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcjS5tX%2FbtqH8byxYPb%2FbXmO2Ql0Gp8P1hcWYrmQK0%2Fimg.png)
[알고리즘 문제] 21. 카드게임
2020. 9. 7. 10:26
문제 풀이/알고리즘 문제풀이
코드 #include using namespace std; int main() { int a[10], b[10], r[10]; int i, ascore = 0, bscore = 0; for (i = 0; i > a[i]; for (i = 0; i > b[i]; for (i = 0; i b[i]) { r[i] = 1; ascore += 3; } else { r[i] = -1; bscore += 3; } } cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbFGwvd%2FbtqIbAxFuTZ%2FJdkMTfwTa4naVdnivUSk00%2Fimg.png)
[알고리즘 문제] 20. 가위 바위 보
2020. 9. 6. 14:53
문제 풀이/알고리즘 문제풀이
#include #include using namespace std; int main() { vector vA; int n, i, temp; cin >> n; for (i = 0; i > temp; vA.push_back(temp); } for (i = 0; i > temp; switch (temp) { case 1: if (vA[i] == 3) cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FoqX4S%2FbtqIar1QUlY%2FaejVaWMHiAKPoLcbhgPU41%2Fimg.png)
[알고리즘 문제] 19. 분노 유발자
2020. 9. 6. 14:21
문제 풀이/알고리즘 문제풀이
#include #include using namespace std; int main() { vector vStudent; int n, i, temp, m, cnt = 0; cin >> n; for (i = 0; i > temp; vStudent.push_back(temp); } m = vStudent[vStudent.size() - 1]; for (i = vStudent.size() - 2; i >= 0; --i) { if (m < vStudent[i]) { cnt++; m = vStudent[i]; } } cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FMlKn3%2FbtqHZlhRAol%2FhpSTu7X9yMgzBPsFMHGYKK%2Fimg.png)
[알고리즘 문제] 18. 층간소음
2020. 9. 5. 22:26
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int n, m, input, i, cnt = 0, res = -1; cin >> n >> m; for (i = 0; i > input; if (input > m) ++cnt; else cnt = 0; if (res < cnt) res = cnt; } cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FmLNLP%2FbtqHO0L3rcI%2F0Jzju044FH4sKNGBiDUlXk%2Fimg.png)
[알고리즘 문제] 17. 선생님 문제
2020. 9. 4. 01:20
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int n, num, res, i, j, temp; cin >> n; for (i = 1; i > num >> res; temp = 0; for (j = 1; j
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbQcqR0%2FbtqHGUrO5Yg%2FBrTid1LeTv9rfOQ6B4JCF0%2Fimg.png)
[알고리즘 문제] 16. Anagram(아나그램 : 구글 인터뷰 문제)
2020. 9. 3. 01:38
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { // 대문자라면 65 빼기 // 소문자라면 97 빼면 0부터 시작하는데, 알파벳이 26개니까 + 26 => 97 - 26 = 71 char a[101], b[101]; int check[52] = { 0 }; int f; bool result = true; cin >> a >> b; for (int i = 0; a[i] != '\0' || b[i] != '\0'; ++i) { f = a[i] >= 97 ? 71 : 65; ++check[a[i] - f]; f = b[i] >= 97 ? 71 : 65; --check[b[i] - f]; } for (int i = 0; i < 52; ++i) { if(check[i] == 0) co..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FyAT9k%2FbtqFkn27Pcu%2FCqjqJhljE381Tawz2MZcCK%2Fimg.png)
[알고리즘 문제] 15. 소수의 개수
2020. 6. 11. 20:52
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int n, i, j, cnt = 0; cin >> n; for (i = 2; i < n; ++i) { bool b = true; for (j = 2; j
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FRMeoN%2FbtqFjqktoK9%2FaZPbNDAqGaDu0XCU3rbvz0%2Fimg.png)
[알고리즘 문제] 14. 뒤집은 소수
2020. 6. 8. 21:40
문제 풀이/알고리즘 문제풀이
#include using namespace std; int reverse(int x) { int res = 0, tmp; while (x > 0) { tmp = x % 10; res = res * 10 + tmp; x = x / 10; } return res; } bool isPrime(int x) { int i; if (x == 1) return false; for (i = 2; i > n; for (i = 0; i > num; temp = reverse(num); if (isPrime(temp)) cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F9tanw%2FbtqFdnpsvDU%2FO8JpjlKdkyjw36AcKanWZk%2Fimg.png)
[알고리즘 문제] 13. 가장 많이 사용된 자릿수
2020. 6. 7. 15:25
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int ch[10]; int i, max = -2147000000, res = -1; char a[101]; cin >> a; for (int i = 0; a[i] != '\0'; ++i) { int idx = a[i] - 48; ch[idx]++; if (ch[idx] == max && idx > res) res = idx; else if (ch[idx] > max) { res = idx; max = ch[idx]; } } /* for (int i = 0; i max) { max = ch[i]; res = i; } }*/ cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fcx3dpN%2FbtqFcM8ZAv7%2FS1EJDtK5n9Nl4XaO2lAap1%2Fimg.png)
[알고리즘 문제] 11. 숫자의 총 개수(small)
2020. 6. 5. 21:25
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int n, i, count = 0, tmp; cin >> n; for (int i = 1; i 0) { tmp /= 10; count++; } } cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FOE8mX%2FbtqEQth4oSV%2Fl6rqbaLx5QJlfgiEYpgh61%2Fimg.png)
[알고리즘 문제] 10. 자릿수의 합
2020. 6. 3. 21:16
문제 풀이/알고리즘 문제풀이
#include using namespace std; int digit_sum(int x) { int sum = 0; for (int i = 1; i > n; for (i = 0; i > a[i]; for (i = 0; i max || (t == max && a[i] > max_n)) { max = t; max_n = a[i]; } } cout > n; for (i = 0; i > num; sum = digit_sum(num); if (sum > max) { max = sum; res = num; } else if (sum == max) res = num > res ?..
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FyrBjP%2FbtqEPlkVCcT%2FwO13y9ns7nQCL7bG3rutZ1%2Fimg.png)
[알고리즘 문제] 09. 모두의 약수
2020. 6. 2. 21:39
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int num, i, j; cin >> num; for (i = 1; i
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdMQeDF%2FbtqEPuWb6xt%2FYVw6hBD1L3mNQuuCXrkHG1%2Fimg.png)
[알고리즘 문제] 08. 올바른 괄호
2020. 6. 1. 20:45
문제 풀이/알고리즘 문제풀이
#include using namespace std; bool check(char * c) { int count = 0; for (int i = 0; c[i] != '\0'; ++i) { if (c[0] == ')' || (c[i+1] == '\0' && c[i] == '(')) return false; if (c[i] == '(') count++; else if (c[i] == ')') count--; } if (count == 0) return true; return false; } int main() { char c[31]; cin >> c; cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcsZwiL%2FbtqEvYj6Q0N%2FsS5uoKH3Pbx8OdLp4OuO7k%2Fimg.png)
[알고리즘 문제] 07. 영어단어 복구
2020. 5. 30. 21:39
문제 풀이/알고리즘 문제풀이
#include #include using namespace std; int main() { int i; char c[101]; gets_s(c); for (i = 0; c[i] != '\0'; i++) { if (c[i] == ' ') continue; if (c[i] >= 65 && c[i]
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcvQcsd%2FbtqEv7sFyuc%2Ft3EtJf5xDbRMxu3uxicjR1%2Fimg.png)
[알고리즘 문제] 06. 숫자만 추출
2020. 5. 29. 16:07
문제 풀이/알고리즘 문제풀이
#include #include using namespace std; int main() { char c[51]; int i, idx = 0, num = 0, cnt = 0; int n[8]{ 0 }; cin >> c; for (i = 0; i = 48 && c[i]
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FkyIZO%2FbtqEuy6bNCg%2FbtyeEn1jv0JyhldnUXH2uK%2Fimg.png)
[알고리즘 문제] 05. 나이 계산
2020. 5. 24. 22:34
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { int a, b, year, gender, result; scanf_s("%d-%d", &a, &b); year = a / 10000; gender = b / 1000000; char c = gender % 2 == 0 ? 'W' : 'M'; result = 20 - year + (gender < 3 ? 100 : 0); cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FoybWB%2FbtqEu53sYkL%2FpP1AS4l0imbSYGllQiTkq0%2Fimg.png)
[알고리즘 문제] 04. 나이 차이
2020. 5. 22. 22:55
문제 풀이/알고리즘 문제풀이
#include using namespace std; int main() { // 초기화 시: max=-2147000000, min=2147000000 // 나이의 범위가 주어지지 않았기 때문에 이렇게 처리하는 것이 훨씬 좋을 것 같다!! //freopen("input.txt", "rt", stdin); int n, i, age, max=2, min=100; cin >> n; for (i = 0; i > age; if (age > max) max = age; if (age < min) min = age; } cout
![thumbnail](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcagNda%2FbtqEvg4Kf5w%2F4Ojm1saqXkRHmJkiDNciyk%2Fimg.png)
[알고리즘 문제] 03. 진약수의 합
2020. 5. 21. 20:26
문제 풀이/알고리즘 문제풀이
코드 #include using namespace std; int main() { int n, i, sum = 1; cin >> n; cout