摘要: //素数 //线性筛选 0是素数,1不是素数 void init(){ notPrice[0]=notPrice[1]=1; for(int i=2;i<n;i++){ if(notPrice[i]==0){ for(int j=i+i;j<n;j+=i){ notPrice[j]=1; } } } 阅读全文
posted @ 2022-04-07 15:47 hunhun5201314 阅读(21) 评论(0) 推荐(0)
摘要: public static int add(int a,int b){ int temp1=a^b; int temp2=(a&b)<<1; while (temp2!=0){ int temp=temp1; temp1=temp1^temp2; temp2=(temp&temp2)<<1; } r 阅读全文
posted @ 2022-03-27 00:25 hunhun5201314 阅读(71) 评论(0) 推荐(0)
摘要: //判断2的幂次方 public static boolean f1(int n){ boolean flag=false; if ((n&(n-1))==0){ flag=true; } return flag; } //判断4的幂次方 public static boolean f2(int n 阅读全文
posted @ 2022-03-27 00:24 hunhun5201314 阅读(186) 评论(0) 推荐(0)
摘要: public static int KMP(String s1,String s2){ //判断两个字符串是否有匹配的可能 if(s1==null||s2==null||s1.length()<1||s1.length()<s2.length()){ return -1; } char []str= 阅读全文
posted @ 2022-03-24 10:23 hunhun5201314 阅读(56) 评论(0) 推荐(0)
摘要: public void Inert_sort(int []array){ //i用来表示数组中的第几个元素在进行插入排序 for (int i=0;i<array.length;i++){ //用来暂时存储array[i]的元素,以便后面使用 int flag=array[i]; //在后面j用来表 阅读全文
posted @ 2022-03-21 14:47 hunhun5201314 阅读(36) 评论(0) 推荐(0)
摘要: if(start==end){ for(int i=0;i<end;i++){ System.out.println(arraay[i]); } }else{ for(int i=start;i<end;i++){ swap(array,i,start); Prem(array,start+1;en 阅读全文
posted @ 2022-03-20 00:03 hunhun5201314 阅读(33) 评论(0) 推荐(0)