일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 연결요소
- c++
- string 메소드
- 표준 입출력
- UI한글변경
- 시간복잡도
- getline
- scanf
- string 함수
- 엑셀
- 프레임워크와 라이브러리의 차이
- double ended queue
- 2557
- k-eta
- 구조체와 클래스의 공통점 및 차이점
- vscode
- 장고란
- 입출력 패턴
- 입/출력
- 이분그래프
- 알고리즘 공부방법
- Django란
- 백준
- Django Nodejs 차이점
- iOS14
- EOF
- Django의 편의성
- 자료구조
- 매크로
- correlation coefficient
- Today
- Total
목록알고리즘/백준풀이5. 문자열 (7)
Storage Gonie
문제 풀이 # C++ - string 배열과 substr을 이용해서 직접정렬을 구현하여 답을 구할 수 있지만 그건 나중에 어차피 학습할 내용이므로 아래의 것을 익히자. #include #include #include #include using namespace std; int main() { string str; cin >> str; int len = str.size(); vector vec; for (int i = 0; i < len; i++) vec.push_back(str.substr(i, len-i)); sort(vec.begin(), vec.end()); for (int i = 0; i < vec.size(); i++) cout
문제 풀이 - 이 문제는 int 의 표현범위 -2,147,483,648 ~ 2,147,483,647 를 넘어간다. (맨앞이 2인 숫자 10자리로 대강 기억하자.) - 따라서 두 숫자를 붙인 스트링을 만들 때 -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 의 표현범위를 가지는 long long 형으로 변환해주어야 한다. # C++ #include #include using namespace std; int main() { string s1; string s2; long long sum = 0; for (int i = 0; i > s1 >> s2; s1.append(s2); sum += stoll(s1); } cout
문제 풀이 # C++ - 왜 13을 더해주고 빼주는지는 a~z까지 나열한 후 직접 해보면 알 수 있음.(a~m까지가 13개 m~z까지가 13개) #include #include using namespace std; string rot13(string s) { for (int i=0; i= 'a' && s[i] = 'n' && s[i] = 'A' && s[i] = 'N' && s[i]
문제 풀이 # C++ #include #include int main() { char a[111]; scanf("%s",a); printf("%d\n",strlen(a)); return 0; } #include char s[111]; int main() { scanf("%s",s); int len = 0; for (int i=0; s[i]; i++) { len += 1; } printf("%d\n",len); } #include #include using namespace std; int main() { string s; cin >> s; cout
문제 풀이 # C++ #include using namespace std; int main() { string s; while (getline(cin, s)) // 공백을 포함하여 통째로 받는다. { int lower = 0; //소문자 개수 int upper = 0; //대문자 개수 int number = 0; //숫자 개수 int space = 0; //공백 개수 for (char x : s) { if (x >= 'a' && x = 'A' && x = '0' && x
문제 풀이 # C++ - count에 이어서 find 함수를 사용하면 쉽고 빠르다. #include using namespace std; int main(void) { ios::sync_with_stdio(false); string s; cin >> s; int len; len = s.size(); for (int i = 'a' ; i
문제 풀이 # C++ - strlen 을 사용하기 위해서는 #include 이 필요하다. 아니면 string 을 사용해서 size 함수 혹은 length 함수를 사용. #include #include using namespace std; int main(void) { ios::sync_with_stdio(false); // 알파벳의 개수를 저장할 배열 초기화 int count[26]; for(int i = 0; i > s; int len; len = strlen(s); for (int i = 0; i < len; i++ ) { int index; index = int(s[i]) - 97; // 'a'..