資源簡介
程序員面試金典 源碼 包含JAVA、C、c++等語言實現

代碼片段和文件信息
#include?
#include?
void?quicksort(int?*nbr?int?n){
??if(n?<=?1)
????return;
??if(n?==?2?&&?nbr[0]?<=?nbr[1])
????return;
??if(nbr?==?NULL)
????return;
??int?pivot?=?(int)(n/2.);
??int?i;
??for(i?=?0;?i?????if(nbr[i]?>?nbr[pivot]?&&?i???????int?temp?=?nbr[pivot];
??????nbr[pivot]?=?nbr[i];
??????nbr[i]?=?temp;
????}
????if(nbr[i]??pivot){
??????int?temp?=?nbr[pivot];
??????nbr[pivot]?=?nbr[i];
??????nbr[i]?=?temp;
????}
??}
??int?*left?=?malloc((pivot?+?1)*sizeof(int));
??int?*right?=?malloc((n?-?pivot?-?1)*sizeof(int));
??for(i?=?0;?i?????left[i]?=?nbr[i];
??for(i?=?0;?i?????right[i]?=?nbr[pivot?+?1?+?i];
??quicksort(left?pivot+1);
??quicksort(right?n-pivot-1);
??for(i?=?0;?i?????nbr[i]?=?left[i];
??for(i?=?0;?i?????nbr[pivot?+?1?+?i]?=?right[i];
??free(left);
??free(right);
}
int?is_sorted(int?*nbr?int?n){
??int?i;
??for(i=0;?i ????if(nbr[i]?>?nbr[i+1])
??????return?0;
??return?1;
}
int?main(){
??int?i;
??int?nbr[5]?=?{10?1?0?5?2};
??int?nbr_small[2]?=?{100?2};
??int?*nbr_null?=?NULL;
??quicksort(nbr?5);
??quicksort(nbr_small?2);
??quicksort(nbr_null?10);
??if(is_sorted(nbr?5))
????printf(“nbr?passed\n“);
??else
????printf(“nbr?failed\n“);
??if(is_sorted(nbr_small?2))
????printf(“nbr_small?passed\n“);
??else
????printf(“nbr_small?failed\n“);
??if(nbr_null?==?NULL)
????printf(“nbr_null?passed\n“);
??else
????printf(“nbr_null?failed\n“);
??return?EXIT_SUCCESS;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......??????2320??2014-07-06?08:33??程序員面試金典?源代碼\.gitignore
????.......??????1565??2014-07-06?08:33??程序員面試金典?源代碼\C\Algorithms\quicksort.c
????.......???????845??2014-07-06?08:33??程序員面試金典?源代碼\C\Chapter_1\Question1_1\ChapQ1.1.c
????.......??????1146??2014-07-06?08:33??程序員面試金典?源代碼\C\Chapter_1\Question1_2\ChapQ1.2.c
????.......??????2735??2014-07-06?08:33??程序員面試金典?源代碼\C\Chapter_1\Question1_3\ChapQ1.3.c
????.......??????1819??2014-07-06?08:33??程序員面試金典?源代碼\C\Chapter_1\Question1_4\ChapQ1.4.c
????.......??????4985??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Chapter?1.vcxproj
????.......??????3329??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Chapter?1.vcxproj.filters
????.......???????850??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\main.cpp
????.......??????1708??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Misc\SimpleHashTable.h
????.......??????2467??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Misc\SimpleHashTable.inl
????.......??????1241??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_1\Question1_1.cpp
????.......???????288??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_1\Question1_1.h
????.......???????658??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_2\Question1_2.cpp
????.......???????160??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_2\Question1_2.h
????.......???????910??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_3\Question1_3.cpp
????.......???????259??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_3\Question1_3.h
????.......???????847??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_3\Question1_3_B.cpp
????.......???????267??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_3\Question1_3_B.h
????.......??????1273??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_4\Question1_4.cpp
????.......???????179??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_4\Question1_4.h
????.......??????1638??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_5\Question1_5.cpp
????.......???????430??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_5\Question1_5.h
????.......??????1427??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_6\Question1_6.cpp
????.......???????363??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_6\Question1_6.h
????.......??????1325??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_7\Question1_7.cpp
????.......???????369??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_7\Question1_7.h
????.......???????813??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_8\Question1_8.cpp
????.......???????257??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?1\Question1_8\Question1_8.h
????.......???????921??2014-07-06?08:33??程序員面試金典?源代碼\c++\Chapter?2\li
............此處省略1554個文件信息
- 上一篇:jsp+sqlserver網絡書店
- 下一篇:TFIDF算法java實現
評論
共有 條評論