标签:
教材:算法导论 2nd edition
2.1-3
1 SEARCHING-VALUE(A,v) 2 for i ← 1 to n 3 if v = A[i] 4 return i 5 return NIL
2.1-4 Formal statement略
1 /** 2 * A,B均为boolean数组,下标从1开始,n为数组长度 3 * 输出长度为n+1的boolean数组C,其中Integer(C)=Interger(A)+Interger(B) 4 **/ 5 ADD-BINARY(A,B,n) 6 upper ← 0 7 c ← new Integer[n+1] 8 for i ← n to 1 9 c[i+1] ← (A[i]+B[i]+upper) % 2 10 upper ← (A[i]+B[i]+upper) / 2 11 c[1] ← upper 12 return C
标签:
原文地址:http://www.cnblogs.com/pulgawang/p/4888142.html