本文介绍了这是什么类型的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! void s_sort(void * base,size_t nmemb,size_t size, int(* compar)(const void *,const void *)) { size_t bytes; unsigned char * array,* after,* i,* j,* k,* p1,* p2,* end,swap; array = base; = nmemb * size + array; if(nmemb(size_t)-1 / 4){ nmemb / = 4; }否则{ nmemb =(nmemb * 3 + 1)/ 7; } while(nmemb!= 0){ bytes = nmemb * size; i = bytes + array; 做{ j = i - bytes; if(compar(j,i)0){ k = i; do { p1 = j; p2 = k; end = p2 + size; 做{ swap = * p1; * p1 ++ = * p2; * p2 ++ = swap; } while(p2!= end); if(bytes + array j){ break; } k = j; j - =字节; } while(比较(j,k)0); } i + = size; } while(i!= after); nmemb =(nmemb * 3 + 1)/ 7; } / *结束来源* / 这是什么类型的?它的工作代码发布了 评估五张卡片。它有多普遍? LSvoid s_sort(void *base, size_t nmemb, size_t size,int (*compar)(const void *, const void *)){size_t bytes;unsigned char *array, *after, *i, *j, *k, *p1, *p2, *end, swap;array = base;after = nmemb * size + array;if (nmemb (size_t)-1 / 4) {nmemb /= 4;} else {nmemb = (nmemb * 3 + 1) / 7;}while (nmemb != 0) {bytes = nmemb * size;i = bytes + array;do {j = i - bytes;if (compar(j, i) 0) {k = i;do {p1 = j;p2 = k;end = p2 + size;do {swap = *p1;*p1++ = *p2;*p2++ = swap;} while (p2 != end);if (bytes + array j) {break;}k = j;j -= bytes;} while (compar(j, k) 0);}i += size;} while (i != after);nmemb = (nmemb * 3 + 1) / 7;}/* end source */What type of sort is this? It''s working code that pete posted forevaluating five card stud. How general is it? LS推荐答案 1)这不是一个C问题,虽然它需要 能够读取C源。 comp.programming可能是一个更好的算法问题论坛。 2)快速浏览一下,看起来Shell的减少 - 增量排序(" Shellsort"): http://www.cs.princeton.edu/~rs/shell/index.html - Eric Sosman es ***** @ acm-dot-org.inva 盖 1)这不是一个C问题,虽然它需要 才能读取C源。 comp.programming可能是一个更好的算法问题论坛。 1) This isn''t really a C question, although it requiresthe ability to read C source. comp.programming might be abetter forum for algorithmic issues. 我对算法属性不是那么感兴趣但我对 C感兴趣。在我读完之后帖子,我以为他们称之为 shell排序,因为你可以用一个shell来移动一个豌豆,就像魔术师那样。显然,有一个名叫壳牌的人。 这是一个关于其复杂性的开放性问题。大约是O(4/3)。I''m not so interested in the algorithmic properties but am interested in theC. Before I read up on it after your post, I thought that they called it ashell sort because of the way you might move a pea around with a shell asmagicians do. Apparently there''s a guy named Shell.It is an open question on its complexity. It is approximately O(4/3). 两个问题: Q1)* next *增量在哪里在upthread源代码中计算? Q2)我在使用以下语法时遇到问题,似乎正在阅读这个 错误 返回int_2 int_1? -1:int_2!= int_1; 有人可以解释一下吗? LSTwo questions:Q1) Where does the *next* increment get calculated in the upthread source?Q2)I have trouble with the following syntax and seem to be reading thiswrongreturn int_2 int_1 ? -1 : int_2 != int_1;Can someone explain? LS 这是一个相当常见的习语。 如果是int_2 int_1,则返回-1。 如果是int_2 == int_1,它返回0. 如果int_2< INT_1,它返回1 - INT主(无效){炭P [] =" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\ \ n",* q =" kl BIcNBFr.NKEzjwCIxNJC" ;; int i = sizeof p / 2; char * strchr(); int putchar(\ ); while(* q) {i + = strchr(p,* q ++) - p; if(i> =(int)sizeof p)i- = sizeof p-1; putchar(p [i] \ ); } return 0;}This is a fairly common idiom.If int_2 int_1, it returns -1.If int_2 == int_1, it returns 0.If int_2 < int_1, it returns 1.--int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\);}return 0;} 这篇关于这是什么类型的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-12 15:18