| | |
| | | import com.anyun.exam.lib.util.ByteUtil; |
| | | import com.safeluck.aykj.utils.BytesUtils; |
| | | |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * MyApplication2 |
| | | * Created by lzw on 2019/3/18. 13:13:42 |
| | |
| | | byte checkcode = calCheckCode(dtas); |
| | | System.out.println(BytesUtils.toHexString(checkcode)); |
| | | } |
| | | |
| | | |
| | | |
| | | public static int[] getRandomInts(int size,int randomMax){ |
| | | Random random = new Random(); |
| | | int[] a=new int[size]; |
| | | int index=0; |
| | | |
| | | while(index<size){ |
| | | System.out.println("---------------"); |
| | | int temp=random.nextInt(randomMax); |
| | | |
| | | if(temp!=0&&!contains(a,temp)){ |
| | | a[index++]=temp; |
| | | } |
| | | } |
| | | |
| | | for(int i=0;i<a.length;i++){ |
| | | System.out.println(a[i]); |
| | | } |
| | | |
| | | |
| | | return a; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | //该方法完成判断temp在a数组中是否包含 |
| | | //包含返回true |
| | | public static boolean contains(int[] a,int temp){ |
| | | |
| | | for(int i=0;i<a.length;i++){ |
| | | if(a[i]==temp){ |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } |