Generate an Activation code
Package jihuoma;//generates activation code: similar to 2hs0-sskj-9hho-a55dpublic class Test {public static void main (string[] args) {String str= ""; for (int i = 1; i <=; i++) {int a= (int) (Math.random ()),//0,1,2,[0,3) take an integer between if (a==0) {str=str+ (char) ((int) ( Math.random () * (' Z '-' a ' + 1)) + ' A ');} if (a==1) {str=str+ (char) ((int) (Math.random () * (' Z '-' a ' + 1)) + ' A ');} if (a==2) {str=str+ (char) ((int) (Math.random () * (' 9 '-' 0 ' + 1)) + ' 0 ');} if (i%4==0&&i<16)//each 4 plus one-representative separation, equal to 16 o'clock does not have to add. {str=str+ '-';}} System.out.println (str);//print output randomly generated activation code}}
Generate 10 Activation codes (more than one layer of loops outside)
Package jihuoma;//generates 10 activation codes public class Test2 {public static void main (string[] args) {for (int j = 0; J < x + +) {//follow Ring 10 times, generate 10 Activation code string str= ""; for (int i = 1; i <=; i++) {//16 times after the loop generates an activation code int a= (int) (Math.random ());//0,1,2if (a==0) {str=str+ (char) ((int) (Math.random () * (' Z '-' a ' + 1)) + ' A ');} if (a==1) {str=str+ (char) ((int) (Math.random () * (' Z '-' a ' + 1)) + ' A ');} if (a==2) {str=str+ (char) ((int) (Math.random () * (' 9 '-' 0 ' + 1)) + ' 0 ');} if (i%4==0&&i<16) {str=str+ '-';}} System.out.println (str);}}}
Generate an activation code using the random number generation method, such as 12hj-9hjf-hhty-kk8g