- 博客(16)
- 资源 (3)
- 问答 (2)
- 收藏
- 关注
原创 倒水问题
题:假设杯子容量为6,3,1。杯子没有刻度。给定初始状态和目标状态,最少需要多少步才能从初始状态转为目标状态。 #include using namespace std; int vol[3] = { 6, 3, 1 }; typedef int state[3]; //定义状态类型 const int MAXSTATE = 1000000; state st[MAXSTATE],
2016-08-25 22:57:06
565
原创 深度优先搜索
深度优先搜索算法: #ifndef DFS_H #define DFS_H #include #include "stdio.h" #include using namespace std; #define NUM 6 typedef struct _stNode { char syb; }stNode; stNode nodeAry[NUM]; int color[NUM
2016-06-04 17:03:51
355
转载 ubuntu自定义分辨率
首先查看当前已有的分辨率: 使用cvt来生成指定分辨率。 顺序执行以下三条命令: sudo xrandr --newmode "1920x1080_60.0" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync sudo xrandr --addmode Virtua
2016-05-31 14:34:20
492
原创 ubuntu16.04安装运行mopidy出现错误
ubuntu安装mopidy出现图示错误: 执行:sudo apt-get install python-gobject-dev即可
2016-05-31 10:28:54
891
原创 广度优先搜索
#include #include #include #include using namespace std; typedef struct _stNode { int syb; }stNode; #define NUM 8 stNode nodeAry[8]; stNode *parent[8]; int dis[8]; int color[8]; list graph[
2016-05-25 16:30:54
332
原创 霍夫曼编码
看了算法导论关于霍夫曼编码的内容,然后做了实现,可能并不是很好,写得比较复杂。//heap.h #ifndef HEAP_H #define HEAP_H #include #include #include typedef struct _letter { int freq; char alpha; char *code; }stLetter; typedef struct
2016-05-20 21:19:04
539
原创 数字字符串解码为字母
题目:将一串数字字符串,解码为一串字母。比如1234,可以为abcd,也可以为lcd,awd,abcd。 思想:采用递归的方式,每两个为一组进行遍历,一组又可以拆分为两个待解字符或者结合为一个待解字符。#include #include #include #include char letter[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', '
2015-10-10 09:28:25
2413
原创 输出从1~n的全排列
思想:采用递归的方式,比如第一次取1,那么剩下的2~n进行全排列,以此类推。 #include #include #include void print(int *pers, int n) { int i =0; for(i = 0; i < n; i++) { printf("%d", pers[i]); } printf("\n"); } /* *pers保存已经排
2015-10-09 20:57:05
2388
原创 因子和阶乘
输入n,把n!=1*2*3*。。。*n的素因子相乘的形式 例:825=3*5^2*11,表示为(0 1 2 0 1)表示0,1,2,0,1个2,3,5,7,11 输入:53 输出:53!=49 23 12 8 4 4 3 2 2 1 1 1 1 1 1 1 思路:split_to_prime采用递归的方式将n进行分解,如果能被m整除,则将m与商在带入函数进行计算,知道为素数。 fact
2015-09-29 21:18:33
430
原创 选择第i小的元素
思想:利用快排的分割函数,判断小于主元素的元素个数是否为i - 1,是则返回,否则继续递归。#include //输出 void print(int array[], int size) { int i = 0; for(i = 0; i < size; i++) { printf("%d ", array[i]); } printf("\n"); } //交换 void
2015-09-22 10:09:13
696
原创 快速排序
思想:以某一元素为基准,将剩余元素拆分为大于该元素和小于该元素的两部分,然后再分别选取基准元素,重复拆分,知道该部分中剩余元素为一个。 #include //输出 void print(int array[], int size) { int i = 0; for(i = 0; i { printf("%d ", array[i]); } print
2015-09-21 14:39:20
317
原创 堆排序
#include //输出 void print(int array[], int size) { int i = 0; for(i = 0; i { printf("%d ", array[i]); } printf("\n"); } //两数交换 void swap(int *a, int *b) { int temp = *a; *a = *
2015-09-20 22:45:23
361
原创 合并排序
#include //合并子序列 void merge(int array[], int start, int mid, int end) { int len_l = mid - start + 1; // 左子串长度 int len_r = end - mid; //右子串长度 int len = 0, len_max = 0; //len:两个字串小值,l
2015-09-16 09:20:09
345
原创 字符驱动练习
/* 驱动模块代码 */ #include #include #include #include #define SUCCESS 0 #define DEVICE_NAME "charDev" #define BUF_LEN 80 MODULE_AUTHOR("HWM"); MODULE_LICENSE("GPL"); static int Major;
2015-08-18 14:32:23
347
原创 linux源码,list_entry阅读心得
第一次写博客,想做点记录,主要想广大网友交流。本人在linux源码上还是新手,希望大家不吝赐教。谢谢。 list_entry定义: #define list_entry(ptr, type, member) \ container_of(ptr, type, member) #define container_of(ptr, type, member) ({
2015-07-18 18:00:03
547
基于qt的组态软件设计
2014-10-14
java使用ftpclient超时问题
2020-03-17
dataframe 分组后应用自定函数计算,为什么第一个索引会应用两边
2019-11-21
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅