]]>閾捐〃鑺傜偣鏁?/title>http://www.shnenglu.com/zhenglinbo/archive/2012/08/17/187433.htmlhoshellyhoshellyThu, 16 Aug 2012 17:43:00 GMThttp://www.shnenglu.com/zhenglinbo/archive/2012/08/17/187433.htmlhttp://www.shnenglu.com/zhenglinbo/comments/187433.htmlhttp://www.shnenglu.com/zhenglinbo/archive/2012/08/17/187433.html#Feedback0http://www.shnenglu.com/zhenglinbo/comments/commentRss/187433.htmlhttp://www.shnenglu.com/zhenglinbo/services/trackbacks/187433.html 瀹炵幇浠g爜濡備笅錛?br />
#include<stdio.h> #include<stdlib.h> typedef struct node *link; struct node{ int item; link next; };
int node_number(link p,int n) { int count=0,i; for(i=0;i<n-1;i++) { p=p->next; } while(p->item) { p->item=0; p=p->next; count++; } return count; }
int main() {
int i,N; link t=(link)malloc(sizeof(node)); t->item=1; t->next=t; link x=t; for(i=2;i<=10;i++) { x = (x->next= (link)malloc(sizeof(node))); x->item=i; x->next=t; } printf("Please input the order of node: "); scanf("%d",&N); printf("total number of nodes is: %d\n",node_number(t,N)); return 0; }
int main() { int k[10]={2,5,6,3,7,8,0,9,12,1},i; printf("The orginal data array is\n"); for(i=0;i<10;i++) printf("%d ",k[i]); quicksort(k,0,9); //浠庡ぇ鍒板皬鎺掑簭 printf("\nThe result of quick sorting for the array is\n"); for(i=0;i<10;i++) printf("%d ",k[i]); return0; }
]]>鐩存帴鎻掑叆鎺掑簭http://www.shnenglu.com/zhenglinbo/archive/2012/03/04/167116.htmlhoshellyhoshellySun, 04 Mar 2012 07:19:00 GMThttp://www.shnenglu.com/zhenglinbo/archive/2012/03/04/167116.htmlhttp://www.shnenglu.com/zhenglinbo/comments/167116.htmlhttp://www.shnenglu.com/zhenglinbo/archive/2012/03/04/167116.html#Feedback0http://www.shnenglu.com/zhenglinbo/comments/commentRss/167116.htmlhttp://www.shnenglu.com/zhenglinbo/services/trackbacks/167116.html#include<stdio.h> int insertsort(int a[],int n)//鐩存帴鎺掑簭娉?/span> { int i,j; for(i=2;i<=n;i++) { a[0]=a[i]; //a[0]浣滀負涓存椂鍙橀噺瀛樺偍a[i] j=i-1; while(j>0&& a[0]>a[j])//浠庡ぇ鍒板皬鎺掑垪 a[j+1]=a[j--]; a[j+1]=a[0]; //灝嗗厓绱燼[0]鎻掑叆鎸囧畾浣嶇疆 } return0; }
int main() { int i,a[11]={-111,2,5,6,3,7,8,0,9,12,1};//a[0]娌℃湁浣跨敤 printf("The orginal data array is\n"); for(i=1;i<=10;i++) printf("%d ",a[i]); insertsort(a,10); printf("\nThe result of insertion sorting for the array is\n"); for(i=1;i<=10;i++) printf("%d ",a[i]); printf("\n"); return0; }