生成银行卡号码:
Action() { char card[19] = {'6','2','2','7','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; int i; int tmp = 0; int tmp2; char tmp3[1]; for (i = 6; i<19; i++) { itoa(rand()%10,tmp3,10); card[i] = tmp3[0]; } for(i = 17; i >= 0; i--){ if((i+1)%2 != 0) { tmp3[0] = card[i]; tmp2 = atoi(tmp3) * 2; tmp = tmp + tmp2/10 + tmp2%10; } else { tmp3[0] = card[i]; tmp = tmp +atoi(tmp3); } } if(tmp%10 == 0) { card[18] = '0'; } else { tmp = 10 - tmp%10; itoa(tmp,tmp3,10); card[18] = tmp3[0]; } lr_save_var(card,19,0,"bankID"); lr_output_message("生成的银行卡号=%s",lr_eval_string("{bankID}")); return 0; }
Action() { //生成随机身份证号 int i = 0; char card[18]; //身份证号码 char tmp[1]; int t; int w[17] = {7 ,9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; // srand(time(NULL)); i = rand()%9; switch (i){ case 0: card[0] = '1'; card[1] = '1'; card[2] = '0'; card[3] = '1'; card[4] = '0'; card[5] = '1'; break; case 1: card[0] = '3'; card[1] = '5'; card[2] = '0'; card[3] = '1'; card[4] = '0'; card[5] = '2'; break; case 2: card[0] = '3'; card[1] = '5'; card[2] = '0'; card[3] = '3'; card[4] = '0'; card[5] = '2'; break; case 3: card[0] = '1'; card[1] = '5'; card[2] = '0'; card[3] = '1'; card[4] = '0'; card[5] = '2'; break; case 4: card[0] = '1'; card[1] = '5'; card[2] = '2'; card[3] = '5'; card[4] = '0'; card[5] = '1'; break; case 5: card[0] = '6'; card[1] = '2'; card[2] = '0'; card[3] = '1'; card[4] = '0'; card[5] = '2'; break; case 6: card[0] = '6'; card[1] = '2'; card[2] = '1'; card[3] = '1'; card[4] = '0'; card[5] = '2'; break; case 7: card[0] = '4'; card[1] = '2'; card[2] = '0'; card[3] = '1'; card[4] = '0'; card[5] = '2'; break; case 8: card[0] = '5'; card[1] = '4'; card[2] = '0'; card[3] = '4'; card[4] = '0'; card[5] = '2'; break; } // srand(time(NULL)); i = rand()%67 + 1925; t = i / 1000; itoa(t,tmp,10); card[6] = tmp[0]; t = i % 1000 / 100; itoa(t,tmp,10); card[7] = tmp[0]; t = i % 1000 % 100; itoa(t,tmp,10); card[8] = tmp[0]; t = i % 1000 % 100 / 10; itoa(t,tmp,10); card[9] = tmp[0]; // srand(time(NULL)); i = rand()%12 + 1; t = i/10; itoa(t,tmp,10); card[10] = tmp[0]; t = i%10; itoa(t,tmp,10); card[11] = tmp[0]; // srand(time(NULL)); i = rand()%28 + 1; t = i/10; itoa(t,tmp,10); card[12] = tmp[0]; t = i%10; itoa(t,tmp,10); card[13] = tmp[0]; // srand(time(NULL)); i = rand()%1000; t = i/100; itoa(t,tmp,10); card[14] = tmp[0]; t = i%100/10; itoa(t,tmp,10); card[15] = tmp[0]; t = i%100%10; itoa(t,tmp,10); card[16] = tmp[0]; t = 0; for(i=0;i<17;i++) { t = t + w[i]*card[i]; } t = t % 11; switch(t) { case 0: card[17] = '1'; break; case 1: card[17] = '0'; break; case 2: card[17] = 'x'; break; case 3: card[17] = '9'; break; case 4: card[17] = '8'; break; case 5: card[17] = '7'; break; case 6: card[17] = '6'; break; case 7: card[17] = '5'; break; case 8: card[17] = '4'; break; case 9: card[17] = '3'; break; case 10: card[17] = '2'; break; } lr_save_var(card,18,0,"infoID"); lr_output_message("身份证号=%s",lr_eval_string("{infoID}")); return 0; }