| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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 | 
                            Tags
                            
                        
                          
                          - back propagation
 - 가끔은_말로
 - 플로이드 와샬
 - 우선 순위 큐
 - 문자열
 - 자바스크립트
 - BFS
 - c++
 - pytorch
 - 이분 탐색
 - 가끔은 말로
 - 다익스트라
 - 회고록
 - lazy propagation
 - DP
 - 백트래킹
 - 조합론
 - dropout
 - Overfitting
 - 미래는_현재와_과거로
 - dfs
 - tensorflow
 - NEXT
 - object detection
 - 알고리즘
 - 크루스칼
 - 분할 정복
 - 세그먼트 트리
 - 너비 우선 탐색
 - 2023
 
                            Archives
                            
                        
                          
                          - Today
 
- Total
 
Doby's Lab
최근 유용하게 쓰는 함수들 C++로 구현해놓은 거 본문
[문자열 더하기]
string strSum(string a, string b) {
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	while (a.length() > b.length()) {
		b += '0';
	}
	while (a.length() < b.length()) {
		a += '0';
	}
	int alone;
	int carry = 0;
	string result;
	for (int i = 0; i < a.length(); i++) {
		alone = ((a[i] - '0') + (b[i] - '0') + carry) % 10;
		result += to_string(alone);
		carry = ((a[i] - '0') + (b[i] - '0') + carry) / 10;
	}
	if (carry > 0) {
		result += to_string(carry);
	}
	reverse(result.begin(), result.end());
	return result;
}
[팰린드롬인지 확인하기 (문자열)]
bool isRight(string temp) {
	if (temp.size() == 1) {
		return 1;
	}
	stack<char> s;
	if (temp.size() % 2 == 0) {
		for (int i = 0; i < (temp.size() / 2); i++) {
			s.push(temp[i]);
		}
		for (int i = temp.size() / 2; i < temp.size(); i++) {
			if (s.top() == temp[i]) {
				s.pop();
			}
			else {
				return 0;
			}
		}
		return 1;
	}
	else {
		for (int i = 0; i < (temp.size() / 2); i++) {
			s.push(temp[i]);
		}
		for (int i = (temp.size() / 2) + 1; i < temp.size(); i++) {
			if (s.top() == temp[i]) {
				s.pop();
			}
			else {
				return 0;
			}
		}
		return 1;
	}
}'PS > Study Note' 카테고리의 다른 글
| SCC 알고리즘 2가지 (0) | 2022.04.02 | 
|---|---|
| [알고리즘] Merge Sort (합병 정렬) 구현 (C++) (0) | 2022.03.01 | 
| [알고리즘] 최소 스패닝 트리 (C++), 크루스칼 알고리즘 (0) | 2021.12.16 | 
| [자료구조] 우선순위 큐, 비교 연산자 (C++) (0) | 2021.11.30 | 
| [알고리즘] 2차원 배열이란 키워드 (0) | 2021.11.24 |