随笔分类 -  C/C++

摘要:CDC,CPaintDC,CClientDC,CWindowDC区别————————————————————————1、首先,对DC进行解释一下:Windows应用程序通过为指定设备(屏幕,打印机等)创建一个设备描述表(Device Context, DC)在DC表示的逻辑意义的“画布”上进行图形的绘制。DC是一种包含设备信息的数据结构,它包含了物理设备所需的各种状态信息。Win32程序在绘制图形之前需要获取DC的句柄HDC,并在不继续使用时释放掉。2、然后,理顺CDC的派生类关系:CObjectpublic |------CDCpublic |------|------CClientDCpu 阅读全文
posted @ 2011-04-19 20:37 Watson.Long 阅读(2369) 评论(0) 推荐(0)
摘要:一个关于字符指针的奇怪问题!************************************问题如下,先看两段代码:代码一:#include "stdio.h"void exchange(char *s1,char *s2);void main(){char *str="abc";exchang(str,str);}void exchange(char *s1,char *s2){char temp;temp=*s1;*s1=*s2;*s2=temp;}代码二:#include "stdio.h"void exchange(c 阅读全文
posted @ 2011-03-25 17:15 Watson.Long 阅读(147) 评论(0) 推荐(0)
摘要:归并排序的实现_by watson.long————————————————————————————#include "stdio.h"void mergesort(int a[],int r[],int left,int right);void merge(int a[],int b[],int left,int mid,int right);void main(int argc,char *argv[]){ int data[10]={9,1,2,4,6,10,23,5,3,56}; int result[10]={0}; int i=0; /*merge sort*/ 阅读全文
posted @ 2011-03-25 09:23 Watson.Long 阅读(179) 评论(0) 推荐(0)
摘要:小根堆的实现——————————————————#include "stdio.h"#include "stdlib.h"#include "string.h"/*minheap struct*/typedef struct hnode{ int heap[100]; int currentsize;}minheapnode,*minheap;/*minheap*/void creatheap(minheap *h,int a[], int n);void siftdown(minheap *h,int i,int m);void s 阅读全文
posted @ 2011-03-25 09:17 Watson.Long 阅读(397) 评论(0) 推荐(0)
摘要:求第K大数程序代码—————————————————————— 1 #include "stdio.h" 2 #include "stdlib.h" 3 #include "string.h" 4 5 int partition(int a[], int left, int right); 6 7 void main() 8 { 9 int a[10]={3,4,18,6,1,2,22,45,67,11};10 int kmax;11 int i;12 int left=0,right=9;13 14 printf("inp 阅读全文
posted @ 2011-03-24 23:54 Watson.Long 阅读(372) 评论(0) 推荐(0)