mirror of
https://github.com/krahets/hello-algo.git
synced 2026-09-01 04:47:12 +00:00
Rename the common modules in Java, C++ and C.
This commit is contained in:
@@ -5,7 +5,6 @@ set(CMAKE_C_STANDARD 11)
|
||||
|
||||
include_directories(./include)
|
||||
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(chapter_computational_complexity)
|
||||
add_subdirectory(chapter_array_and_linkedlist)
|
||||
add_subdirectory(chapter_stack_and_queue)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: MolDuM (moldum@163.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 随机返回一个数组元素 */
|
||||
int randomAccess(int *nums, int size) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Zero (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 在链表的节点 n0 之后插入节点 P */
|
||||
void insert(ListNode *n0, ListNode *P) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Zero (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 列表类简易实现 */
|
||||
struct myList {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Guanngxu (446678850@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 二分查找(双闭区间) */
|
||||
int binarySearch(int *nums, int len, int target) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Created Time: 2023-04-15
|
||||
* Author: Gonglja (glj0@outlook.com)
|
||||
*/
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 函数 */
|
||||
int func() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: sjinzh (sjinzh@gmail.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 常数阶 */
|
||||
int constant(int n) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: sjinzh (sjinzh@gmail.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 生成一个数组,元素为 { 1, 2, ..., n },顺序被打乱 */
|
||||
int *randomNumbers(int n) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Guanngxu (446678850@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 哈希表默认数组大小 */
|
||||
# define HASH_MAP_DEFAULT_SIZE 100
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
#define MAX_SIZE 5000
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Gonglja (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 哈希表 */
|
||||
struct hashTable {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 方法一:暴力枚举 */
|
||||
int *twoSumBruteForce(int *nums, int numsSize, int target, int *returnSize) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Guanngxu (446678850@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 线性查找(数组) */
|
||||
int linearSearchArray(int *nums, int len, int target) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Listening (https://github.com/L-Super)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 冒泡排序 */
|
||||
void bubbleSort(int nums[], int size) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com), Guanngxu (446678850@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 计数排序 */
|
||||
// 简单实现,无法用于排序对象
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Listening (https://github.com/L-Super)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 插入排序 */
|
||||
void insertionSort(int nums[], int size) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Guanngxu (446678850@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 合并左子数组和右子数组 */
|
||||
// 左子数组区间 [left, mid]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 元素交换 */
|
||||
void swap(int nums[], int i, int j) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */
|
||||
int digit(int num, int exp) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Gonglja (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 基于环形数组实现的双向队列 */
|
||||
struct arrayDeque {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Zero (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 基于环形数组实现的队列 */
|
||||
struct arrayQueue {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Zero (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
#define MAX_SIZE 5000
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Gonglja (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 双向链表节点 */
|
||||
struct doublyListNode {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Gonglja (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 基于链表实现的队列 */
|
||||
struct linkedListQueue {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Zero (glj0@outlook.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 基于链表实现的栈 */
|
||||
struct linkedListStack {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* AVL Tree */
|
||||
struct aVLTree {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 二叉搜索树 */
|
||||
struct binarySearchTree {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* Driver Code */
|
||||
int main() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 层序遍历 */
|
||||
int *levelOrder(TreeNode *root, int *size) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "../include/include.h"
|
||||
#include "../utils/common.h"
|
||||
|
||||
/* 辅助数组,用于存储遍历序列 */
|
||||
int *arr;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
add_executable(include
|
||||
include_test.c
|
||||
include.h print_util.h
|
||||
list_node.h tree_node.h
|
||||
uthash.h)
|
||||
@@ -0,0 +1,5 @@
|
||||
add_executable(utils
|
||||
common_test.c
|
||||
common.h print_util.h
|
||||
list_node.h tree_node.h
|
||||
uthash.h)
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* File: include.h
|
||||
* File: common.h
|
||||
* Created Time: 2022-12-20
|
||||
* Author: MolDuM (moldum@163.com)、Reanon (793584285@qq.com)
|
||||
*/
|
||||
@@ -4,7 +4,7 @@
|
||||
* Author: Reanon (793584285@qq.com)
|
||||
*/
|
||||
|
||||
#include "include.h"
|
||||
#include "common.h"
|
||||
|
||||
void testListNode() {
|
||||
int nums[] = {2, 3, 5, 6, 7};
|
||||
Reference in New Issue
Block a user