某种代码生成的规则

mtr MTR
  1. 本字符串由八位字符组成。
  2. 字符中第1、2、4位是字母,3、4、5、6、7、8位是数字。
  3. 当第一位字母是QWERTYUIOP中任意字母时,3、4位必定是偶数。
  4. 当第二位字母是ASDFGHJKLM中任意字母时,4、5、6位必定是偶数。
  5. 当第四位字母是ZXCVBNMASD中任意字母时,3、4、5、6、7、8位中有一半是偶数,一半是奇数。
  6. 当一二位字母相同时,数字中必定存在2。
  7. 当二四位字母相同时,数字中必定存在3。
  8. 当一四位字母相同时,数字中必定存在5。
  9. 当三位字母都相同时,数字中必定存在6。

以下为生成代码所用的部分源代码。(写的很烂

烂尾了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;



string letter(int t){
string ltr [] ={"M","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
return ltr[t];
}

int randfunc();
int randfunci();

void seeit(string v[],int b[]){
cout <<v[0] <<v[1] <<v[2] <<b[1] <<v[3] <<b[2] <<b[3] <<b[4] <<b[5];
}

int main(){
unsigned seed;
seed = time(0);
srand(seed);
string code[4];
code[0]="CODE: ";
int seedr[]={randfunc(),randfunc(),randfunc(),randfunc(),randfunc(),randfunc(),randfunc(),randfunc()};
code[1]=letter(seedr[1]);
code[2]=letter(seedr[2]);
code[3]=letter(seedr[3]);
int codeNum[6];
codeNum[1]=seedr[4];
codeNum[2]=seedr[5];
codeNum[3]=seedr[6];
codeNum[4]=seedr[7];
codeNum[5]=seedr[8];
seeit(code,codeNum);
}

int randfunc(){
return rand() % 10;
}

int randfunci(){
return int(rand() % 10);
}
  • 本文标题:某种代码生成的规则
  • 本文作者:mtr
  • 创建时间:2024-01-01 09:49:51
  • 本文链接:https://blog.mtr.pub/2024/01/01/a-code-gen/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
 评论
此页目录
某种代码生成的规则