|
donpps
初级用户
 
积分 56
发帖 20
注册 2006-4-23
状态 离线
|
『楼 主』:
请教,序列号的计算问题?
使用 LLM 解释/回答一下
问题如下:
输入序列号(仅由数字和大写字母组成的字符串),先判定序列号输入是否正确,如不符要求(仅由数字和大写字母组成的字符串),返回重新输入,如符合要求,则开始计算注册码。取第1个字符的(ASCII编码)前1位的字符(如A为@,9为8),取第2个字符的(ASCII编码)前2位的字符(如A为?,9为7),取第3个字符的(ASCII编码)前4位的字符(如A为=,9为5),取第4个字符的(ASCII编码)前5位的字符(如A为<,9为4),取倒数第4个字符的(ASCII编码)前1位的字符,取倒数第3个字符的(ASCII编码)前2位的字符,取倒数第2个字符的(ASCII编码)前4位的字符,取倒数第1个字符的(ASCII编码)前5位的字符,(中间的几位字符不参与计算),组成一个8(或6,4,2)位字符的注册码。如序列号:W1D0W7M5A0J593459609490 注册号:V/@+825+
用excel作比较容易。用p处理,不知怎么搞!想用如下文本文件作查询,先以字符查acsi码,再做减法计算,再用计算结果查询字符,可惜写来写去,总写不好。或许用debug的方案还简单些。请教最优解法,谢谢。
+ 43
, 44
- 45
. 46
/ 47
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
: 58
; 59
< 60
= 61
> 62
? 63
@ 64
A 65
B 66
C 67
D 68
E 69
F 70
G 71
H 72
I 73
J 74
K 75
L 76
M 77
N 78
O 79
P 80
Q 81
R 82
S 83
T 84
U 85
V 86
W 87
X 88
Y 89
Z 90
The problem is as follows:
Input a serial number (a string consisting only of digits and uppercase letters). First, determine whether the input of the serial number is correct. If it does not meet the requirements (a string consisting only of digits and uppercase letters), return to re-enter. If it meets the requirements, start to calculate the registration code. Take the character that is the previous 1 bit of the ASCII code of the first character (for example, A is @, 9 is 8), take the character that is the previous 2 bits of the ASCII code of the second character (for example, A is?, 9 is 7), take the character that is the previous 4 bits of the ASCII code of the third character (for example, A is =, 9 is 5), take the character that is the previous 5 bits of the ASCII code of the fourth character (for example, A is <, 9 is 4), take the character that is the previous 1 bit of the ASCII code of the fourth from the last character, take the character that is the previous 2 bits of the ASCII code of the third from the last character, take the character that is the previous 4 bits of the ASCII code of the second from the last character, take the character that is the previous 5 bits of the ASCII code of the last character, (the middle several characters do not participate in the calculation), and form an 8 (or 6, 4, 2)-bit character registration code. For example, the serial number: W1D0W7M5A0J593459609490, the registration number: V/@+825+
It is easier to do with Excel. With p processing, I don't know how to do it! I want to use the following text file for query, first check the ASCII code by character, then do the subtraction calculation, and then query the character with the calculation result. Unfortunately, I always can't write it well. Maybe the solution with debug is simpler. Please ask for the optimal solution, thank you.
+ 43
, 44
- 45
. 46
/ 47
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
: 58
; 59
< 60
= 61
> 62
? 63
@ 64
A 65
B 66
C 67
D 68
E 69
F 70
G 71
H 72
I 73
J 74
K 75
L 76
M 77
N 78
O 79
P 80
Q 81
R 82
S 83
T 84
U 85
V 86
W 87
X 88
Y 89
Z 90
|
|
2006-12-30 07:40 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
p处理也能算sn,顶~
p processing can also be considered as sn, top~
|
|
2006-12-30 13:24 |
|
|
tigerpower
中级用户
   大师兄
积分 377
发帖 99
注册 2005-8-26
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
使用 mawk :
C:\>mawk "BEGIN{for(k=43;k<=90;k++){m=sprintf(\"%c\",k);n2i=k};for(i=1;i==1;){printf \"\nPlease enter the SN: \";getline;if(length($0)<8){print \"SN must more than 8 characters\";continue};for(j=1;j<=length($0);j++){if (substr($0,j,1)!~//){print \"All characters must in !!!\";break}};if (j>length($0)){i=0}};key_gen(0,-1);key_gen(1,-2);key_gen(2,-4);key_gen(3,-5);key_gen(-4,-1);key_gen(-3,-2);key_gen(-2,-4);key_gen(-1,-5);print \"The KEY is: \" key};function key_gen(p,q){key=sprintf(\"%s%c\",key,n2i+q)}"
更多命令行工具,请到本论坛的
WinPE、PowerShell板块(点击进入)
Use mawk :
C:\>mawk "BEGIN{for(k=43;k<=90;k++){m=sprintf(\"%c\",k);n2i=k};for(i=1;i==1;){printf \"\nPlease enter the SN: \";getline;if(length($0)<8){print \"SN must more than 8 characters\";continue};for(j=1;j<=length($0);j++){if (substr($0,j,1)!~//){print \"All characters must in !!!\";break}};if (j>length($0)){i=0}};key_gen(0,-1);key_gen(1,-2);key_gen(2,-4);key_gen(3,-5);key_gen(-4,-1);key_gen(-3,-2);key_gen(-2,-4);key_gen(-1,-5);print \"The KEY is: \" key};function key_gen(p,q){key=sprintf(\"%s%c\",key,n2i+q)}"
For more command-line tools, please go to the WinPE, PowerShell section of this forum (click to enter)
|
|
2006-12-31 12:46 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
tigerpower 真乃牛人,Orz
tigerpower is really an expert, Orz
|
|
2007-5-10 01:34 |
|
|
dqls889
初级用户
 
积分 68
发帖 36
注册 2006-12-19
状态 离线
|
|
2007-5-17 00:18 |
|
|