본문 바로가기

알고리즘/문자와 문자열38

1357 뒤집힌 덧셈 1234567891011121314151617181920212223242526#include #include #include using namespace std; int rev(string str) { int len = str.length(); int rst = 0; for (int i = 0; i 2020. 2. 29.
문자열 정리> 기본 기법들 모음 2020. 1. 12.
9971 The Hardest Problem Ever 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include #include #include using namespace std; char toReal(char c) { if ((int)c end; }}Colored by Color Scriptercs 1. string 클래스를 배열처럼 활용할 수 있다 2. cin 입력을 여러번 받아도, 그 경우에 buffer 를 비워줘야한다.그러기 위해서 getchar() 를 썼다 2020. 1. 7.
4659 비밀번호 발음하기 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include #include int jamo(char c) { if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) { return 1; } else { return 2; }} int main() { while (1) { int flag = 1; char arr[30] = { 0 }; scanf("%s", &arr); //탈출조건 if (!strcmp(arr, "end")) break; //모음 포함 int len = strlen(arr); fo.. 2020. 1. 7.
10545 뚜기뚜기메뚜기 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100#include #include int dial[10] = { 0 }; void press(char c, char bef) { if (97 2020. 1. 6.
3077 임진왜란 12345678910111213141516171819202122232425262728293031323334353637383940#include #include #include #include using namespace std; map mp; int main() { int n; scanf("%d", &n); for (int i = 0; i > tmp; mp[tmp] = i + 1; } int idx[2505] = { 0 }; for (int i = 1; i > str; idx[i] = mp.find(str)->second; } int sum = 0; for (int i = 1; i 2020. 1. 6.
4949 균형잡힌 세상 12345678910111213141516171819202122232425262728293031323334353637383940414243#include #include #include using namespace std; int main() { while (1) { string str; getline(cin, str); if (str == ".") break; char stk[105] = { 0 }; int curIdx = -1; int len = str.size(); for (int i = 0; i 2020. 1. 6.
9933 민균이의 비밀번호 123456789101112131415161718192021222324252627282930313233343536373839404142#include #include #include #include #include using namespace std; map mp; int main() { int n; scanf("%d", &n); while (n--) { string str; cin >> str; string rev = str; reverse(rev.begin(), rev.end()); if (str == rev) { int len = rev.size(); int idx = len / 2; printf("%d %c", len, str.at(idx)); break; } else if ((mp.find(re.. 2020. 1. 6.
3986 좋은 단어 1234567891011121314151617181920212223242526272829303132333435363738394041424344#include #include int isGood(char* arr) { int len = strlen(arr); char stk[100005] = { 0 }; int curIdx = -1; for (int i = 0; i 2020. 1. 6.
10551 STROJOPIS 123456789101112131415161718192021222324252627282930313233343536373839404142434445#include #include int index(char c){ if (c == '1' || c == 'Q' || c == 'A' || c == 'Z') { return 0; } else if (c == '2' || c == 'W' || c == 'S' || c == 'X') { return 1; } else if (c == '3' || c == 'D' || c == 'C' || c == 'E') { return 2; } else if (c=='4' || c == 'R' || c == 'F' || c == 'V' || c == '5' || c == 'T' ||.. 2020. 1. 6.
5218 알파벳 거리 1234567891011121314151617181920212223242526272829303132#include #include int dist(int idx, char* a, char* b) { int chA = (int)a[idx]; int chB = (int)b[idx]; if (chA 2020. 1. 5.
11656 접미사 배열 1234567891011121314151617181920212223242526#include #include #include #include using namespace std; map mp; int main() { string str; cin >> str; int len = str.size(); for (int i = 0; i 2020. 1. 5.