摘要: 一个关于字符指针的奇怪问题!************************************问题如下,先看两段代码:代码一:#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 阅读(140) 评论(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 阅读(171) 评论(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 阅读(388) 评论(0) 推荐(0) 编辑