English | 中文
EN: This repository contains C implementations of five classic algorithm problems, with test data and run instructions. It is suitable for algorithm practice, coursework review, and portfolio display.
中文:本仓库收录 5 个经典算法题的 C 语言实现,包含测试数据与运行说明,适合算法练习、课程复习与项目展示。
八皇后/
八皇后问题.c
背包/
背包问题.c
背包测试数据.txt
哈夫曼/
哈夫曼编码.c
README.md
tobetrans.dat
简单测试.txt
测试数据.txt
滑雪场/
滑雪场问题.c
小测试数据.txt
滑雪场测试数据.txt
木棒加工/
木棒加工问题.c
木棒加工测试数据.txt
Run the following command in the corresponding problem directory. / 在对应目录下执行:
gcc -std=c11 -O2 -Wall -Wextra -o 程序名 源文件名.cExample / 示例:
cd 八皇后
gcc -std=c11 -O2 -Wall -Wextra -o 八皇后问题 八皇后问题.c
./八皇后问题- File / 文件:
八皇后/八皇后问题.c - Function / 功能:Outputs all valid solutions and the total count. / 输出 8 皇后所有可行解与总数量。
- Input / 输入:None / 无。
- Output / 输出:Coordinate list for each solution and the total solution count. / 每个解的坐标列表与总解数。
- File / 文件:
背包/背包问题.c - Function / 功能:Enumerates all feasible combinations under a given capacity. / 在给定容量下枚举所有可行组合。
- Input / 输入:Capacity, item count, and item volume list. / 背包容量、物品数量、物品体积列表。
- Output / 输出:All feasible solutions and the total solution count. / 所有可行解与解的总数。
- Test data / 测试数据:
背包/背包测试数据.txt
- File / 文件:
哈夫曼/哈夫曼编码.c - Function / 功能:Builds a Huffman tree and performs encoding/decoding. / 构建哈夫曼树并进行编码/解码。
- Input / 输入:Characters and weights during initialization;
tobetrans.datduring encoding. / 初始化时输入字符与权重;编码时读取tobetrans.dat。 - Output / 输出:Encoded
codefileand decodedtextfile. / 编码文件codefile与解码结果textfile。 - Notes / 说明:See
哈夫曼/README.mdfor detailed steps. /哈夫曼/README.md内含更详细的操作步骤。
- File / 文件:
滑雪场/滑雪场问题.c - Function / 功能:Finds the longest ski path length and route. / 求最长滑行路径长度与具体路线。
- Input / 输入:Matrix dimensions and height matrix. / 矩阵行列数与高度矩阵。
- Output / 输出:Longest path length, start point, and path. / 最长路径长度、起点与路径。
- Test data / 测试数据:
滑雪场/滑雪场测试数据.txt
- File / 文件:
木棒加工/木棒加工问题.c - Function / 功能:Minimizes preparation time and outputs the processing order. / 最小化准备时间并给出加工顺序。
- Input / 输入:Stick count plus each stick's length and weight. / 木棒数量与每根木棒的长度、重量。
- Output / 输出:Minimum preparation time and processing order. / 最少准备时间与加工顺序。
- Test data / 测试数据:
木棒加工/木棒加工测试数据.txt
- Programs use standard input by default. / 默认使用标准输入(终端交互)。
- Huffman coding generates temporary files:
huffman,codefile,codeprint,textfile, andtreeprint; they are ignored by.gitignore. / 哈夫曼编码会生成临时文件:huffman、codefile、codeprint、textfile、treeprint,这些文件已加入.gitignore。