[C++] vector 이용해 string, int 저장하기 (1181 단어정렬 - C++)
2022. 9. 18. 17:59
스스로 공부하기/C++
https://blockdmask.tistory.com/64 [C++] Pair 클래스 정리 및 예제 (vector, sort) 안녕하세요! BlockDMask 입니다. 이번에는 C++의 Pair 클래스에 대해 간단히 정리 해보려합니다. 클래스사용법, 함수 및 간단한 예제를 준비해봤습니다. 감사합니다. 1) Pair 클래스란. 두 객체를 하 blockdmask.tistory.com 문자열을 pair에 저장할 수 있다. 단, string 헤더 파일을 포함시켜 string을 사용해야 함. https://boycoding.tistory.com/178 C++ 05.03 - 문자열, std::string 05.03 - 문자열, std::string 처음으로 작성한 C++ 프로그램은 다음과 같다. #include ..
[알고리즘] C++ STL vector, iostream
2022. 9. 18. 15:41
스스로 공부하기/알고리즘
vector https://life-with-coding.tistory.com/411 [C++][STL] Vector 기본 사용법 및 예제 활용 인트로 안녕하세요! 오늘은 C++ STL중 하나인 벡터(Vector)의 기본 함수와 예제에 대해서 알아보도록 하겠습니다. 벡터 기본함수는 push_back, pop_back, front, back, clear, begin, end, rbegin, rend, reverse.. life-with-coding.tistory.com iostream https://coding-factory.tistory.com/479 [C++] 입력문 / 출력문 (cin, cout) 사용법 & 예제 C언어에서는 에 있는 scanf, printf를 통해서 입출력문을 사용합니다. 물론 C+..
[알고리즘] 정렬; C++ STL <algorithm>, 내장함수 sort, compare 함수 만들어 넣기 (백준 2751 좌표 정렬하기)
2022. 9. 18. 15:41
스스로 공부하기/알고리즘
STL algorithm이란? c언어를 쉽게 이용할 수 있도록 만든 헤더 파일 중 하나인 algorithm을 이용해 쉽게 정렬을 할 수 있다. 정렬 - 퀵 정렬, 버블 정렬, 병합 정렬, 선택 정렬 버블 정렬의 시간 복잡도는 O(n^2), 병합 정렬의 시간 복잡도는 O(nlogn) 이다. 병합 정렬에 대해서는 앞선 포스팅 https://chocodingdiary.tistory.com/27 에서 알아본 바 있다. (물론 1151번 문제는 당시에 해결하지 못했다) STL 헤더 algorithm을 이용하여 sort함수를 호출시키면 쉽게 오름차순으로 정렬을 할 수 있다. #include int main(){ int arr[10]; //array 값은 알아서 넣어준다. sort(arr, arr+10) // arr..
[백준] 1373번 2진수 8진수
2022. 9. 7. 22:32
solving/C, C++
소스코드 #include #include int main (){ char a[1000001]; scanf("%s", &a); int len = strlen(a); char array[333334]; int i, index = 0, cur = 0, temp = 0, b = 1, c=0; for(i=len-1; i>=0; i--){ temp = temp + (a[i] - '0')*b; b = b*2; cur++; if(cur==3){ array[c++] = temp+'0'; cur = 0; b = 1; temp = 0; } if (i == 0) array[c] = temp+'0'; } if (c != 0 && len%3 == 0) c--; for(i=c; i>=0; i--){ printf("%d", arra..
[백준] 1356번 유진수 (숫자 배열로 받기, 배열에서 index 이동시키기)
2022. 9. 5. 18:42
solving/C, C++
소스코드 #include int main (){ int a, i; scanf("%d", &a); int number[10]; int len = 0; int n = a; while (n!=0){ number[len] = n % 10; len++; n = n/10; } int ans, ans1, ans2; for (int temp = 1; temp
[백준] 1296번 팀 이름 정하기 (변수 설정, strcmp)
2022. 9. 4. 19:21
solving/C, C++
소스코드 #include #include int main(){ char name[21]; int a, i, j; scanf("%s", &name); scanf("%d", &a); int namelen = strlen(name); int nameL = 0, nameO = 0, nameV = 0, nameE = 0; for (i=0; i
[백준] 1236번 성 지키기 (이차원 배열)
2022. 9. 2. 17:35
solving/C, C++
소스코드 #include int main(){ int a, b, i, j; scanf("%d %d", &a, &b); char castle[a][b]; for (i=0; i
[백준] 1032번 명령 프롬프트
2022. 9. 1. 15:47
solving/C, C++
소스코드 #include #include int main (){ int N, i, j; scanf("%d", &N); char a[N][51]; for(i=0; i