#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int a, x1, x2, s;
string str1[2] = {"A1910", "A1423"};
srand((unsigned)time(NULL));
a = rand() % 10;
x1 = rand() % 10;
s = rand() % 2;
for(int i = 0; i < 10; i++)
{
if((x1 + i) % 10 == 4)
{
x2 = i;
break;
}
}
cout << str1[s] << a << a << x1 << x2 << a << endl;
return 0;
}
Private Function GetKey() As String Dim str1(2) As String Dim a As Integer, x1 As Integer, x2 As Integer, s As Integer str1(1) = "A1910" str1(2) = "A1423" Randomize a = Int(Rnd * 10) x1 = Int(Rnd * 10) s = Int(Rnd * 2) + 1 For i = 0 To 9 If (x1 + i) Mod 10 = 4 Then x2 = i Exit For End If Next i GetKey = str1(s) & a & a & x1 & x2 & a End Function
原文:http://www.cnblogs.com/hoy0a1d/p/5880211.html