Algorithm
-
1181 단어 정렬/11650 좌표 정렬하기/11651 좌표 정렬하기2/2750 수 정렬하기/10989 수 정렬하기3/10814 나이순 정렬Algorithm/baekjoon 2022. 2. 18. 22:42
1. 1181 단어 정렬 https://www.acmicpc.net/problem/1181 1181번: 단어 정렬 첫째 줄에 단어의 개수 N이 주어진다. (1 ≤ N ≤ 20,000) 둘째 줄부터 N개의 줄에 걸쳐 알파벳 소문자로 이루어진 단어가 한 줄에 하나씩 주어진다. 주어지는 문자열의 길이는 50을 넘지 않는다. www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int n; cin >> n; string* arr = new string[n]; for (int i =..
-
1032 명령 프롬프트/1085 직사각형에서 탈출/1259 팰린드롬수/15829 HashingAlgorithm/baekjoon 2022. 2. 14. 11:26
1. 1032 명령 프롬프트 https://www.acmicpc.net/problem/1032 #include #include using namespace std; char arr[5][15]; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int forn; cin >> forn; string *orders=new string [forn]; for (int i = 0; i > str1; orders[i] = str1; } string output=""; for (int j = 0; j < orders[0].size(); j++) { char a; bool flag = true; for (int..
-
2167 이차원 배열의 합/10798 세로읽기Algorithm/baekjoon 2022. 2. 13. 23:03
1.2167 이차원 배열의 합 https://www.acmicpc.net/problem/2167 #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int n, m; cin >> n >> m; int** arr = new int* [n]; for (int i = 0; i > arr[i][j]; } } int forn; cin >> forn; for (int a = 0; a < forn; a++) { int i, ..
-
2161 카드1Algorithm/baekjoon 2022. 2. 12. 14:01
2161번: 카드1 (acmicpc.net) 2161번: 카드1 N장의 카드가 있다. 각각의 카드는 차례로 1부터 N까지의 번호가 붙어 있으며, 1번 카드가 제일 위에, N번 카드가 제일 아래인 상태로 순서대로 카드가 놓여 있다. 이제 다음과 같은 동작을 카드가 www.acmicpc.net 외쳐라 벡터 갓! 큐로 풀면 더 쉬운 방법이 있지만 벡터를 활용해보고 싶어서 벡터로만 풀었다. #define _CRT_SECURE_NO_WARNINGS #include #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int num; cin >> num; vectorvec; vecto..
-
1924 2007년Algorithm/baekjoon 2022. 2. 12. 13:01
1924번: 2007년 (acmicpc.net) #define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int month; int day; int sumday=0; cin >> month>>day; int imonth = 1; for (int s = 0; s < month - 1; s++) { switch (imonth) { case 1: sumday += 31; imonth++; break; case 2: sumday += 28; imonth++; break; case 3: sumday += 31; imonth++; ..
-
2028 자기복제수Algorithm/baekjoon 2022. 2. 12. 10:45
2028번: 자기복제수 (acmicpc.net) 2028번: 자기복제수 어떤 자연수 N을 제곱했을 때, 그 제곱수의 맨 뒷자리에 원래의 수 N이 다시 나타나면, 우리는 그 수 N을 자기복제수라고 한다. 예를 들면, 5의 제곱은 52는 25이고 25의 맨 뒷자리에 원래의 수 5가 www.acmicpc.net #define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int num; int fornum = 0; cin >> fornum; for (int z = 0; z > num; int..
-
1120 문자열Algorithm/baekjoon 2022. 2. 11. 23:31
1120번: 문자열 (acmicpc.net) 1120번: 문자열 길이가 N으로 같은 문자열 X와 Y가 있을 때, 두 문자열 X와 Y의 차이는 X[i] ≠ Y[i]인 i의 개수이다. 예를 들어, X=”jimin”, Y=”minji”이면, 둘의 차이는 4이다. 두 문자열 A와 B가 주어진다. 이때, A의 www.acmicpc.net 실버 4인 문제....! 여러번에 걸쳐서 풀었다. 솔루션을 안보고 온전히 내 힘으로 풀었다는 뿌듯함이 남은 문제이다ㅎㅎ 컴파일에러가 떴었는데, string을 char형 배열로 바꿔주는 strcpy()를 사용할 때는 #include을 해줘야 하더라. #define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace..
-
05 스택Algorithm/baekjoon 2022. 1. 26. 18:59
1. 백준 10773 10773번: 제로 (acmicpc.net) 10773번: 제로 첫 번째 줄에 정수 K가 주어진다. (1 ≤ K ≤ 100,000) 이후 K개의 줄에 정수가 1개씩 주어진다. 정수는 0에서 1,000,000 사이의 값을 가지며, 정수가 "0" 일 경우에는 가장 최근에 쓴 수를 지우고, 아닐 경 www.acmicpc.net (1) 소스코드 #include #include using namespace std; int main() { int len; cin >> len; stack s; while (len) { int element; cin >> element; if (element == 0) { s.pop(); } else { s.push(element); } len--; } int s..