摘要: 以下代码为什么会出错呢?不理解啊,只能研究研究了。 1 void main(){ 2 unsigned long i =0,*p,*p1; 3 p = (unsigned long *)malloc(10000); 4 p1 = p; 5 6 for(i = 0;i < 9999;i++){ 7 *p1 = 0x100; 8 p1++; 9 }10 free(p);11 }VC运行时,貌似是进入了死循环。难道是类型不兼容造成了什么问题?待解。。。 阅读全文
posted @ 2012-08-01 08:09 cnlixl 阅读(122) 评论(2) 推荐(0) 编辑
摘要: 求斐波纳契数列第n个数的两种实现方法。 1 public class TestFibo { 2 3 public static void main(String[] args){ 4 System.out.println(f(7)); 5 System.out.println(fn(7)); 6 } 7 8 //递归实现 9 public static long f(int index){10 11 if(index<1){12 System.out.p... 阅读全文
posted @ 2012-08-01 07:55 cnlixl 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 用冒泡算法实现对日期的排序 1 //日期类,包含年月日的信息。重写toString 2 //方法,输出年月日信息。 3 public class Date { 4 5 public int year ,month,day; 6 7 public Date(int year,int month,int day){ 8 this.year = year; 9 this.month = month;10 this.day = day;11 }12 13 public String toString()... 阅读全文
posted @ 2012-08-01 07:47 cnlixl 阅读(133) 评论(0) 推荐(0) 编辑