본문 바로가기

반응형

Algorithm_BOJ(백준)/문자열

(36)
[백준 3028 c++ O] 창영마을 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 using namespace std; // [백준 3028 c++ O] 창영마을 // 문제: 3가지 스왑 명령을 입력받아 공의 마지막 위치 출력 // 접근: 문자열로 명령 입력-> swap 명령으로 2개의 원소 스왑 // 시간복잡도: O(50) // 풀이: // swap(원소, 원소2) , 2ㅜ개의 원소 교환 // string.find(찾고자 하는 원소) : 찾은 원소의 첫 인덱스 반환 #de..
[백준 2908 c++ O] 상수 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 using namespace std; // [백준 2908 c++ O] 상수 // 문제: // 접근: 문자로 입력 -> 순서 뒤집기 -> 크기비교 -> 최대값 출력 // 시간복잡도: O() // 풀이: // 개념: // :reverse(a.begin(), a.end()); ,무자열이나 벡터 역순으로 뒤집음 int main() { ios::sync_with_stdio(false); // 계산시간 단축 // cin,scan..
[백준 1152 c++ V] 단어의 개수 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1152 c++ V] 단어의 개수 // 문제: 단어의 갯수 출력 // 접근1: while로 계속 cin 하면 됨 // 시간복잡도: O() , // 풀이: int c = 0; string s; int main() { ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류 cin.tie(nullpt..
[백준 11656 c++ O] 접미사 배열 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 11656 c++ O] 접미사 배열 // 문제: 문자열을 입력받고, 모든 접미사를 사전순으로 출력 // 접근1: 접미사 배열 추출(완전탐색) -> 정렬 // 접근2: 접미사 배열 추출(substr 이용) -> 정렬 -> 개인적으로 이게 더 간편, 시간복 // 시간복잡도: O() , // 풀이: /..
[백준 10824 c++ O] 네 수 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 10824 c++ O] 네 수 // 문제: // 접근: 숫자 이어붙히기 -> 문자열 문제 -> 문자열 수로 변환후 계산 // 질문: // 시간복잡도: O(1) , // 풀이: // 수가 커서 longlong 사용 int main() { ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류 cin.tie(..
[백준 11655 c++ O] ROT13 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 11655 c++ O] ROT13 // 문제: // 접근: getline 으로 공백포함 string으로 입력하고 순환하는 인덱스 더해줌 // 시간복잡도: O(100) , // 풀이: int main() { ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류 cin.tie(nu..
[백준 2743 c++ O] 단어 길이 재기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 2743 c++ O] 단어 길이 재기 // 문제: // 접근: string으로 입력하고 문자갯수 배열에 저장 // 시간복잡도: O(n) , // 풀이: int main() { ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류 cin.tie(nullptr); cout.tie(nullptr);// 입출력 시간 단축 // 이것을 쓰..
[백준 10820 c++ O] 문자열 분석 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 10820 c++ O] 문자열 분석 // 문제: 문자열 입력받고 소문자, 대문자, 숫자, 공백 갯수 출력 // 접근: getline 으로 입력하고 완전탐색 // 시간복잡도: O(n*t) // 풀이: int c1, c2, c3, c4; string s; int main() { ios::sync_with_stdio(false)..

반응형