Java
import java.util.Random; import java.util.Arrays; public class RandJava{ public static void main(String args[]){ int []seeds = {10,23,7,19,1,22,7}; System.out.println(Arrays.toString(seeds)); for(int i=0; i<6; i++){ Random r = new Random(seeds[i]); System.out.println(r.nextInt(33)+1); } Random r = new Random(seeds[6]); System.out.println(r.nextInt(16)+1); } }
结果
Ruby
seeds = [10,23,7,19,1,22,7] print seeds puts for i in seeds[0..5] srand(i) puts rand(33)+1 end srand(seeds[6]) puts rand(16)+1
结果
时间: 2024-10-12 12:08:25