摘要: 1、冒泡排序在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒。即:每当两相邻的数比较后发现它们的排序与排序要求相反时,就将它们互换。冒泡排序是稳定的。算法时间复杂度O(n2)--[n的平方]main(){ int a... 阅读全文
posted @ 2014-11-15 21:55 jamsbwo 阅读(1738) 评论(0) 推荐(0) 编辑
摘要: #include #include #include void main(){ srand( (unsigned)time( NULL ) ); for(int i=0;i<100000;i++){ cout<<rand()<<endl; }} //rand... 阅读全文
posted @ 2014-11-15 21:26 jamsbwo 阅读(108) 评论(0) 推荐(0) 编辑
摘要: //生成N个小于N的随机数,存入数组a,转存到文件data.txtvoid RandToFile(int *a){ srand( (unsigned)time( NULL ) ); //初始化随机数 for(int i=0;i<N;i++) { a[i]=(int)ran... 阅读全文
posted @ 2014-11-15 21:25 jamsbwo 阅读(179) 评论(0) 推荐(0) 编辑
摘要: //从文件中读出数据void ReadFromFile(int a[]){ int i=0; FILE *fp; if((fp=fopen("data.txt","r"))==NULL){ printf("file read error!"); exit... 阅读全文
posted @ 2014-11-15 21:21 jamsbwo 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 基本思路,标记起点,得到终点,相减除以每份的秒数#includeclock_t begin,stop;//开始记录时间 begin=clock();//你要测试时间的程序算法程序();stop=clock();//获得测试程序运行的时间printf("%ld",(stop-begin/CLOCKS_... 阅读全文
posted @ 2014-11-15 21:06 jamsbwo 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 分两个类(这里就不引入包了,太长,复制下来放到eclipse里面智能提示就能导包了)1.主类MyStar.java,创建主窗口public class MyStar { static Dimension screen = Toolkit.getDefaultToolkit().getScree... 阅读全文
posted @ 2014-11-15 20:56 jamsbwo 阅读(247) 评论(0) 推荐(0) 编辑
©2014 to