프로그래밍 언어20 FrameLayout 에서 Thread를 이용한 이미지(또는 애니메이트) 그리기 //SurfaceHolder와 SurfaceHolder.Callback 적용...이것들이 어디에 쓰이는지 모른다 //아무래도 FrameLayout일때 쓰이는것 같은데 사용법은 잘 모름.. //SurfaceHolder는 직접 접근할수가 없다고 한다 //그래서 SurfaceHolder.Callback을 이용해서 접근한다고 한다. //그래서 여기서 클래스 안에 클래스를 하나 더 적용해서 (쓰래드 상속 받은 클래스) //그 클래스에서 그리기, 키입력을 받아 쓴다. //layout 에서 으로 이미지를 그리고 배치할수 있으나 //FrameLayout 이 아무래도 전체 그리기로는 알맞는것 같다. //비트맵,png 이미지 하나 그리는데 소스가 너무 많다.. 헷깔린다. package com.chiree.myimagevi.. 프로그래밍 언어/android 2009. 10. 29. 해시 테이블 (hash table) // 해시 테이블이기는하나 완벽하지 않다.. // 리스트 10칸에 10칸씩 리스트 되어야 맞는 것 같으나 그냥 리스트 10칸에서 다시 해시가 적용된다.. #include #include #include #define TABLE_SIZE 10; typedef struct _node NODE; struct _node { int key; NODE *next; }; int hash_func(int key) { int h; h = key % TABLE_SIZE; return h; } int hsc_init(NODE a[],int *np,int N) { int i; for(i=0;inext = a[tri].next; /* a[tri]는 테이블의 첫라인만 가리킬뿐 값은 들어있지않다. */ t->key = key; /.. 프로그래밍 언어/프로그래밍 2009. 1. 18. 트리 #include #include #include #include typedef struct node NODE; struct node { int key; NODE *parent; NODE *left; NODE *right; }; NODE *root; NODE* node_search(int key, NODE *root) { NODE *s; s = root->left; while(key != s->key && s != NULL) { if(key key ) s = s->left; if(key > s->key ) s = s->right; } if(s == NULL) return NULL; else return s; } NODE * node_insert(int key) { NODE *p,*s; p = ro.. 프로그래밍 언어/프로그래밍 2009. 1. 18. 연결 리스트 (문장<이름>) #include #include #include #include typedef struct node NODE; struct node { char x[6]; NODE *prev; NODE *next; }; NODE *head = NULL; NODE *tail = NULL; NODE* Find_Node(char *x) { NODE *node; node = (NODE*)malloc(sizeof(NODE)); node = head->next; while(node != tail) { if(strcmp(node->x,x) next != tail) { node = node->next; continue; } else return node; if( strcmp(node->x,x) == 0 ) .. 프로그래밍 언어/프로그래밍 2009. 1. 18. 연결 리스트 (한 글자) #include #include #include typedef struct node NODE; typedef struct node { char x[3]; NODE *prev; NODE *next; }NODE; NODE *head = NULL; NODE *tail = NULL; NODE* Find_Node(char *x) { NODE *node; node = (NODE*)malloc(sizeof(NODE)); node = head->next; while(node != tail) { if( strcmp(node->x,x) x,x) == 0) return node; else if( strcmp(node->x,x) > 0 ) return n.. 프로그래밍 언어/프로그래밍 2009. 1. 18. 퀵정렬 #include void quick_sort(int a[],int n) { int v,t; int i,j; if(n>1) { v = a[n-1]; i = -1; j = n-1; while(1) { while(a[++i] v); if( i >=j ) break; t = a[i]; a[i] = a[j]; a[j] = t; } t = a[i]; a[i] = a[n-1]; a[n-1] = t; quick_sort(a,i); quick_sort(a+i+1,n-i-1); } } void main() { int q; int a[10] = {6,3,1,4,2,9,7,0,8,5}; quick_sort(a,10); for(q=0;q 프로그래밍 언어/프로그래밍 2009. 1. 18. 원형큐 #include #define MAX 10 int front,rear; char queue[MAX]; void init_queue() { front = rear = 0; } void clear_queue() { front = rear; } int put(char* ch) { if( (rear+1)%MAX == front ) return -1; queue[rear] = *ch; rear = ++rear % MAX; return 0; } int get(char* ch) { if( rear == front ) return -1; *ch = queue[front]; front = ++front % MAX; return 0; } void main() { char a,b,c; init_queue(); put("1".. 프로그래밍 언어/프로그래밍 2009. 1. 18. 스택 #include #include #define MAX 10 int top; char stack[MAX]; void init_stack() { top = -1; } int push(char* ch) { if(top >= MAX-1) return -1; stack[++top] = *ch; } int put(char* ch) { if( top < 0 ) { printf("\nfailed\n"); return -1; } *ch = stack[top--]; } void main() { char a,b,c,d; init_stack(); put(&b); put(&c); put(&d); printf("%c%c%c",a,b,c); } 프로그래밍 언어/프로그래밍 2009. 1. 17. 이전 1 2 다음