01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| //定义个变量用于保存注册码的每一位的值
int one, two, three, four, five, six, seven, eight, nine;
//给注册码的第位去一个随机值
one = rand() % 10;
//竟然注册码的第位和第位之和大于,那么就取
four = 9 - one;
//注册码的第位必须大于,可以就取值为
two = 6;
//注册码的第位必须小于
five = rand() % 3;
//注册码的第、、之和的结果除以的余数必须和注册码的第位相等
//先给第位取一个随机
three = rand() % 10;
six = (one + three + four) % 10;
//注册码其余位的取值没有限制,取随机值
seven = rand() % 10;
eight = rand() % 10;
nine = rand() % 10;
CString result;
//格式化字符串
result.Format(_T("%d%d%d%d%d%d%d%d%d"), one, two, three, four, five, six, seven, eight, nine);
//将注册码设置到文本框中显示
m_code.SetWindowTextW(result);
|