摘要: This is a list of codes used in C++ to change the text color:black - 30red - 31green - 32brown - 33blue - 34magenta - 35cyan - 36lightgray - 37Now these are the basic colours.Usage of "\033[":This is to handle the console cursor. I do not have a complete reference so I ask people who know 阅读全文
posted @ 2012-12-29 14:23 Yuan Ping 阅读(804) 评论(0) 推荐(0) 编辑
摘要: 成功在Ubuntu 10.04下源码编译安装bochs 2.4.5,主要是在配置Bochs的过程中出现了太多错误了。如果出现1、checking for C compiler default output file name… configure: error: C compiler cannot create executables解决方法: apt-get install libc6-dev2、configure: error: C++ preprocessor "/lib/cpp" fails sanity check解决方法:apt-get install buil 阅读全文
posted @ 2012-12-29 14:21 Yuan Ping 阅读(406) 评论(1) 推荐(0) 编辑
摘要: 安装命令如下:1.添加软件源# rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm2.更新yum 缓存# yum makecache3.安装播放器和解码器# yum install ffmpeg ffmpeg-libs gstreamer-ffmpeg xvidcore libdvdr 阅读全文
posted @ 2012-12-29 14:21 Yuan Ping 阅读(164) 评论(0) 推荐(0) 编辑
摘要: C语言/C++怎样产生随机数:这里要用到的是rand()函数, srand()函数,C语言/C++里没有自带的random(int number)函数。(1) 如果你只要产生随机数而不需要设定范围的话,你只要用rand()就可以了:rand()会返回一随机数值, 范围在0至RAND_MAX 间。RAND_MAX定义在stdlib.h, 其值为2147483647。例如: 1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int main(int argc, char *argv[]) 5 { 6 int i=0; 7 for(i= 阅读全文
posted @ 2012-12-29 00:37 Yuan Ping 阅读(737) 评论(0) 推荐(0) 编辑
摘要: 先取一个小于n的整数d1作为第一个增量,把文件的全部记录分成d1个组。所有距离为d1的倍数的记录放在同一个组中。先在各组内进行直接插入排序;然后,取第二个增量d2<d1重复上述的分组和排序,直至所取的增量dt=1(dt<dt-l<…<d2<d1),即所有记录放在同一组中进行直接插入排序为止。更多信息请参考:http://baike.baidu.com/view/178698.htmC语言代码: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <memory.h> 4 # 阅读全文
posted @ 2012-12-27 21:41 Yuan Ping 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 归并(Merge)排序法是将两个(或两个以上)有序表合并成一个新的有序表,即把待排序序列分为若干个子序列,每个子序列是有序的。然后再把有序子序列合并为整体有序序列。更多信息请参考:http://baike.baidu.com/view/90797.htmC语言代码: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <memory.h> 4 #include <time.h> 5 6 void init(int *array, int count) 7 { 8 int n = 0; 9 s 阅读全文
posted @ 2012-12-26 22:31 Yuan Ping 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 快速排序(Quicksort)是对冒泡排序的一种改进。设要排序的数组是 A[0]……A[N-1],首先任意选取一个数据(通常选用第一个数据)作为关键数据,然后将所有比它小的数都放到它前面,所有比它大的数都放到它后面, 这个过程称为一趟快速排序。值得注意的是,快速排序不是一种稳定的排序算法,也就是说,多个相同的值的相对位置也许会在算法结束时产生变动。更多信息请参考:http://baike.baidu.com/view/115472.htmC语言代码: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <me 阅读全文
posted @ 2012-12-25 23:00 Yuan Ping 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 插入排序使用的是增量(incremental)方法;在排好子数组A[1..j-1]后,将A[j]插入,形成排好序的子数组A[1..j]。更多信息请参考:http://baike.baidu.com/view/396887.htmC语言代码: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <memory.h> 4 #include <time.h> 5 6 void init(int *array, int count) 7 { 8 int n = 0; 9 srand((unsigne 阅读全文
posted @ 2012-12-24 22:39 Yuan Ping 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 每一趟从待排序的数据元素中选出最小(或最大)的一个元素,顺序放在已排好序的数列的最后,直到全部待排序的数据元素排完。 选择排序是不稳定的排序方法。更多信息请参考:http://baike.baidu.com/view/547263.htmC语言代码: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <memory.h> 4 #include <time.h> 5 6 void init(int *array, int count) 7 { 8 int n = 0; 9 srand((un 阅读全文
posted @ 2012-12-24 22:37 Yuan Ping 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序(BubbleSort)的基本概念是:依次比较相邻的两个数,将小数放在前面,大数放在后面。即在第一趟:首先比较第1个和第2个数,将小数放前,大数放后。然后比较第2个数和第3个数,将小数放前,大数放后,如此继续,直至比较最后两个数,将小数放前,大数放后。至此第一趟结束,将最大的数放到了最后。在第二趟:仍从第一对数开始比较(因为可能由于第2个数和第3个数的交换,使得第1个数不再小于第2个数),将小数放前,大数放后,一直比较到倒数第二个数(倒数第一的位置上已经是最大的),第二趟结束,在倒数第二的位置上得到一个新的最大数(其实在整个数列中是第二大的数)。如此下去,重复以上过程,直至最终完成排序 阅读全文
posted @ 2012-12-23 10:47 Yuan Ping 阅读(271) 评论(0) 推荐(0) 编辑