일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- function
- application.mk
- Join
- unalias
- halliday
- Call
- Post
- solution
- array
- 강좌
- 현재언어
- Avr
- PORTG
- selectc
- 하이퍼 터미널
- 0x
- php
- is_array
- android studio
- mathemetica
- 파일존재
- mysql
- 단축키
- C++
- Get
- SQL
- Java
- cocos2d-x
- 월별 카운트
- 점점변하는값
- Today
- Total
목록컴퓨터 이야기/C++ (25)
코딩도사의 코드정리
fill_n 으로 값을 채우기 int testArray[10][10] = {0,}; fill_n(*testArray, 4, 5); for(int i=0; i
// Robert Jenkins' 32bit hash function unsigned __int32 hash(unsigned __int32 key) { key += (key22); key += (key9); key += (key2); key += (key12); return key; } // Thomas Wang's hash function unsigned __int32 hash32(unsigned __int32 key) { key = ~key + (key 12); key += (key > 4); key += (key 16); return key; } unsigned __int64 hash64(unsigned __int64 key) { key = ~key + (key 24); key += (key 14)..
JNI 타입별 사용 예제가 잘 나와있는 게시물 http://lhh3520.tistory.com/141
template class CircularQueue { private: Node* node; // 노드 배열 int capacity; // 큐의 용량 int front; // 전단의 인덱스 int rear; // 후단의 인덱스 public: CircularQueue(int capacity) { this->capacity = capacity + 1; // 노드 배열의 크기는 실제 용량에서 1을 더한 크기 (더미 공간 때문) node = new Node[this->capacity]; // Node 구조체 capacity + 1개를 메모리 공간에 할당한다 front = 0; rear = 0; // 전단과 후단의 초기화 } ~CircularQueue() { delete []node; // 노드 배열 소멸 } v..
일반적으로 new/delete 를 통해서 메모리를 할당하는것은 비용을 발생시키고보기에 위험해 보입니다.C/C++ 에선 메모리를 할당 하기 위해서 시스템 콜(OS 내부 함수를 요청)을 해야만 하는데 이는 생각보다 큰 비용을 발생 시킵니다. 그래서 할당을 미리 해놓고 꺼내오고 해제된 메모리를 다시 쓰는 방식으로 재활용을 해야하는데, 라이브러리를 잘 짜기가 힘이 듭니다.boost 로 해결할 수 있습니다. #include #include #include using namespace std; struct SomeObject { SomeObject() { static int no=0; cout
,
예전에 KLDP에 음수에 대한 나머지 연산질문을 올린적이 있었다. 허접한 질문에도 불구하고 성심성의껏 다들 댓글을 달아주셨다. ------------------------------------------------------------------------------------------------------------------------------------------ 나머지 연산자를 쓰다가 음수를 생각하게 되었습니다. 예를 들어서 (-3) % 2 는 1 이 될 수도 있고 -1 이 될 수도 있는거 같습니다. 한번 궁금해서 여러 프로그램에 이 식을 넣고 답을 기다렸습니다. 먼저 MS 의 VC는 답을 -1 로 내놓았습니다. 윈도우즈 내장 계산기는 답을 -1 로 내놓았습니다. 하지만, MS Excel 은 ..
[옛날 쓴글 가져오기 - mmoz] 제가 간단히 아는 ㅇ명령어로만 해봤는데 결과가 아주 비참하군요!! 셀러론 1Ghz 입니다. __declspec(naked) int mmojz_strlen(const char* s) { __asm { push ebp mov ebp, esp } __asm { push ecx push esi mov ecx, -1 mov esi, dword ptr[ebp+8]; cld l: lodsb inc ecx cmp al, 0 jne l mov eax, ecx pop esi pop ecx } __asm { pop ebp ret } } int mmojz2_strlen(const char* ch) { int i=0; while (*ch++) i++; return i; } int main()..
#include #include #include #include #include using namespace std; #ifdef mycom ifstream fin("input"); #else #define fin cin #endif vector v; vector orders; int N, P, R; unsigned long long counter=0; void back(int order) { if(v.size() == orders.size()) { vector arr; for(int i=0; ii; j--) { if(arr[j] > arr[i]) { allsmall = false; break; } } if(allsmall) // arr[i] 가 rightable 하다 { myr++; } } if(myr..
#include #include #include #include #include using namespace std; #ifdef mycom ifstream fin("input"); #else #define fin cin #endif char chess[100][100] = {0,}; int n, k; long long total = 0; bool possible(int y, int x) { int newy = y; int newx = x; for( ; newy >= 0 && newx >= 0; newy--, newx--) { if(chess[newy][newx] == true) { return false; } } newy = y; newx = x; for( ; newy < n && newx < n; n..
vector v; vector select; void back(int order) { if(select.size() == v.size()) { for(int i=0; i
vector v; vector select; void back(bool sel) { if(select.size() == v.size()) { for(int i=0; i
#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef mycom ifstream fin("input"); #else #define fin cin #endif class team { public: int score; int wincounter; int goaldiff; int manygoal; int gamecounter; string teamname; //////////// int drawcounter; int losecounter; int sibalgoal; team() { score = 0; wincounter =..
#include #include #include #include #include #include #include #include using namespace std; #ifdef mycom #include ifstream fin("input"); #else #define fin cin #endif vector A; vector B; int main() { int testcase; testcase = 1; fin >> testcase; int hours; string solution; solution.resize(10000); for(int i=1; i> n; for(int j=1; j> temp; A.push_back(temp); } sort(A.begin(), A.end()); //saram 에 대한 ..
#include #include #include #include #include #include #include #include #include using namespace std; //#define mycom #ifdef mycom #include ifstream fin("input"); #else #define fin cin #endif using namespace std; int main() { int casenumber; fin >> casenumber; for(int i=1; i> headnumber; vector s; for(int j=1; j> temp; s.push_back(temp); } int nmin = numeric_limits::max(); for(vector::iterator i..