锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国内精品久久久久久久久,久久se精品一区二区影院,久久精品国产99久久久古代http://m.shnenglu.com/JonsenElizee/category/13504.htmlSoftware Developing Blog
<BR>
<BR>
"An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look."
<BR>
"Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity."
<BR>
<BR>
------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard zh-cnThu, 21 Oct 2010 17:13:14 GMTThu, 21 Oct 2010 17:13:14 GMT60Quicker Quick-Sort http://m.shnenglu.com/JonsenElizee/archive/2010/09/23/127418.htmlJonsenElizeeJonsenElizeeThu, 23 Sep 2010 07:24:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/09/23/127418.htmlhttp://m.shnenglu.com/JonsenElizee/comments/127418.htmlhttp://m.shnenglu.com/JonsenElizee/archive/2010/09/23/127418.html#Feedback0http://m.shnenglu.com/JonsenElizee/comments/commentRss/127418.htmlhttp://m.shnenglu.com/JonsenElizee/services/trackbacks/127418.html鍏充簬蹇熸帓搴?/strong>
One of these things is not like the other. Real refers to actual elapsed
time; User and Sys refer to CPU time used only by the process.
*Real is wall clock time - time from start to finish of the call.
This is all elapsed time including time slices used by other processes
and time the process spends blocked (for example if it is waiting for
I/O to complete).
*User is the amount of CPU time spent in user-mode code (outside the
kernel) within the process. This is only actual CPU time used in
executing the process. Other processes and time the process spends
blocked do not count towards this figure.
*Sys is the amount of CPU time spent in the kernel within the
process. This means executing CPU time spent in system calls within the
kernel, as opposed to library code, which is still running in
user-space. Like 'user', this is only CPU time used by the process.
User+Sys will tell you how much actual CPU time your process used.
婧愪唬鐮?/font>
鏍稿績綆楁硶瀵規瘮鍥?/font>
quick.c婧愪唬鐮?/font>
1#include <stdio.h> 2#include <string.h> 3#include <stdlib.h> 4#include <time.h> 5 6void quick(char* str, int low, int hig); 7void swap(char* a, char* b); 8 9int main() 10{ 11char ary[] = 錛忥紡26錛?0闀跨殑瀛楃涓叉暟緇勶紝鍐呭鍙傝冧笂鍥俱?/span> 12char* str = ary; 13 printf("calling quick"); 14 quick(str, 0, strlen(str)-1); 15return0; 16} 17 18void quick(char* str, int low, int hig) { 19if(low >= hig) return; 20 srand(time(NULL)); 21// get a random key 22//swap(str + low, str + low + (rand() % (hig - low + 1))); 23int i = low, j = hig +1, key = str[low]; 24while(1) 25 { 26while(++i <= hig && str[i] <= key); 27while(--j >= low && str[j] > key); 28if(i > j) break; // no need to do swap 29 swap(str + i, str + j); 30 } 31 swap(str + low, str + i -1); // swap key to i-1 position 32 quick(str, low, i -2); 33 quick(str, i, hig); 34} 35 36void swap(char* a, char* b) { 37if(a == b) return; 38*a ^=*b; *b ^=*a; *a ^=*b; 39} 40
myquick.c婧愪唬鐮?/font>
1#include <stdio.h> 2#include <string.h> 3#include <stdlib.h> 4#include <time.h> 5 6void myquick(char* str, int low, int hig); 7void swap(char* a, char* b); 8 9int main() 10{ 11char ary[] =錛忥紡26錛?0闀跨殑瀛楃涓詫紝鍚宷uick.c鐨勮緭鍏ャ?/span> 12char* str = ary; 13 printf("calling myquick"); 14 myquick(str, 0, strlen(str)-1); 15return0; 16} 17 18void myquick(char* str, int low, int hig) { 19if(low >= hig) return;// no need to sort elements 20// elements in the right of [m] are not sorted 21int m = low, i = low, j = hig, key = low; 22// skip any elements that <= [key] 23while(i <= hig && str[i] <= str[key]) {i++; m++;} 24// skip elements > [key] 25while(j >= low && str[j] > str[key]) j--; 26// initially, i==j is impossible 27while(i <= j) { 28// swap small one to m-position 29if(str[i] <= str[key]) { swap(str + m++, str + i); } 30 i++; 31 } 32 swap(str + low, str + m-1); 33 myquick(str, low, m -2); 34 myquick(str, m, hig); 35return; 36} 37 38void swap(char* a, char* b) { 39if(a == b) return; 40*a ^=*b; *b ^=*a; *a ^=*b; 41} 42