반응형 문제 해결238 [백준] [C++] 11718번 그대로 출력하기 https://www.acmicpc.net/problem/11718 11718번: 그대로 출력하기 입력이 주어진다. 입력은 최대 100줄로 이루어져 있고, 알파벳 소문자, 대문자, 공백, 숫자로만 이루어져 있다. 각 줄은 100글자를 넘지 않으며, 빈 줄은 주어지지 않는다. 또, 각 줄은 공백으로 시 www.acmicpc.net 코드 #include #include using namespace std; int main() { string str; while (true) { getline(cin, str); if (str == "") break; cout 2023. 1. 20. [백준] [C++] 11655번 ROT13 https://www.acmicpc.net/problem/11655 11655번: ROT13 첫째 줄에 알파벳 대문자, 소문자, 공백, 숫자로만 이루어진 문자열 S가 주어진다. S의 길이는 100을 넘지 않는다. www.acmicpc.net 코드 #include #include using namespace std; int main() { string str; getline(cin, str); for (int i = 0; i = 78 && str[i] = 110 && str[i] = 65 && str[i] = 97 && str[i] 2023. 1. 19. [백준] [C++] 11170번 0의 개수 https://www.acmicpc.net/problem/11170 11170번: 0의 개수 N부터 M까지의 수들을 종이에 적었을 때 종이에 적힌 0들을 세는 프로그램을 작성하라. 예를 들어, N, M이 각각 0, 10일 때 0을 세면 0에 하나, 10에 하나가 있으므로 답은 2이다. www.acmicpc.net 코드 #include using namespace std; int main() { int n, first, last; cin >> n; for (int i = 0; i > first >> last; for (int j = first; j = 10) { if (num % 10 == 0) count++; num /= 10; } } cout 2023. 1. 19. [백준] [C++] 11365번 !밀비 급일 https://www.acmicpc.net/problem/11365 11365번: !밀비 급일 당신은 길을 가다가 이상한 쪽지를 발견했다. 그 쪽지에는 암호가 적혀 있었는데, 똑똑한 당신은 암호가 뒤집으면 해독된다는 것을 발견했다. 이 암호를 해독하는 프로그램을 작성하시오. www.acmicpc.net 코드 #include #include using namespace std; int main() { string str; while (true) { getline(cin, str); if (str == "END") break; for (int i = str.length() - 1; i >= 0; i--) cout 2023. 1. 19. [백준] [C++] 9086번 문자열 https://www.acmicpc.net/problem/9086 9086번: 문자열 입력의 첫 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 10)가 주어진다. 각 테스트 케이스는 한 줄에 하나의 문자열이 주어진다. 문자열은 알파벳 A~Z 대문자로 이루어지며 알파벳 사이에 공백은 없으 www.acmicpc.net 코드 #include using namespace std; int main() { int n; string str; cin >> n; for (int i = 0; i > str; cout 2023. 1. 19. [백준] [C++] 5218번 알파벳 거리 https://www.acmicpc.net/problem/5218 5218번: 알파벳 거리 첫째 줄에 테스트 케이스의 수 (> n; for (int i = 0; i > str1 >> str2; cout = str1[j]) distance = str2[j] - str1[j]; else distance = (str2[j] + 26) - str1[.. 2023. 1. 19. [백준] [C++] 1157번 단어 공부 https://www.acmicpc.net/problem/1157 1157번: 단어 공부 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. www.acmicpc.net 코드 #include using namespace std; const int COUNT = 26; int main() { string str; int arr[COUNT] = { }; cin >> str; int max = -1; int maxIndex; for (int i = 0; i < str.length(); i++) { str[i] = toupper(str[i]); int num = str[i] - 65; arr[num]++.. 2023. 1. 19. [백준] [C++] 10808번 알파벳 개수 https://www.acmicpc.net/problem/10808 10808번: 알파벳 개수 단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다. www.acmicpc.net 코드 #include using namespace std; const int ALPHA = 26; int main() { string str; int alphabet[ALPHA] = { }; cin >> str; for (int i = 0; i < str.length(); i++) { int num = str[i] - 97; alphabet[num]++; } for (int i = 0; i < ALPHA; i++) cout 2023. 1. 18. [백준] [C++] 10821번 정수의 개수 https://www.acmicpc.net/problem/10821 10821번: 정수의 개수 숫자와 콤마로만 이루어진 문자열 S가 주어진다. 이때, S에 포함되어있는 정수의 개수를 구하는 프로그램을 작성하시오. S의 첫 문자와 마지막 문자는 항상 숫자이고, 콤마는 연속해서 주어지지 www.acmicpc.net 코드 #include using namespace std; int main() { string str; int count = 1; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == ',') count++; } cout 2023. 1. 18. [백준] [C++] 11721번 열 개씩 끊어 출력하기 https://www.acmicpc.net/problem/11721 11721번: 열 개씩 끊어 출력하기 첫째 줄에 단어가 주어진다. 단어는 알파벳 소문자와 대문자로만 이루어져 있으며, 길이는 100을 넘지 않는다. 길이가 0인 단어는 주어지지 않는다. www.acmicpc.net 코드 #include #include using namespace std; int main() { string str; cin >> str; int size = str.length(); for (int i = 0; i < size; i++) { cout 2023. 1. 18. [백준] [C++] 11720번 숫자의 합 https://www.acmicpc.net/problem/11720 11720번: 숫자의 합 첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다. www.acmicpc.net 코드 #include using namespace std; int main() { int n, sum = 0; char arr; cin >> n; for (int i = 0; i > arr; sum += (arr - 48); } cout 2023. 1. 18. [백준] [C++] 11944번 NN https://www.acmicpc.net/problem/11944 11944번: NN 첫 번째 줄에는 N, M이 주어진다. (1 ≤ N, M ≤ 2016) www.acmicpc.net 코드 #include #include using namespace std; int main() { string n; int m; cin >> n >> m; int num = stoi(n); string str = ""; for (int i = 0; i m) cout 2023. 1. 18. 이전 1 2 3 4 5 6 ··· 20 다음 반응형