
算法
文章平均质量分 65
老古董v
这个作者很懒,什么都没留下…
展开
-
求最大公约数最终算法
if( (b&1)==0 && (a&1)==0){//如果两个数都是偶数, return gcd(a>>1,b>>1)<<1;//等于 gcd(a/2,b/2)*2;的写法。 } else if( (a&1)==1 && (b&1)==0){//如果a是奇数,b是偶数 return gcd(a,b>>1); } else if( (a&1)==0 && (b&1)==1){//如果原创 2016-10-17 14:29:07 · 308 阅读 · 0 评论 -
高效率的求出最大公约数
暴力查找: public int getGreatestCommonDivisor(int a,int b){ int big = a>b ? a:b; int small = a<b ? a:b; if(big%small==0){ return small; } for(int i原创 2016-10-16 18:05:18 · 307 阅读 · 0 评论 -
java实现随机洗牌算法
code: import java.util.Random;class Card { public String num; public String suit; Card(String n,String s) { this.num=n; this.suit=s; } public String toString()转载 2016-04-14 23:20:36 · 825 阅读 · 1 评论