parallel-comparator-200-入土为安的第九天

简介: parallel-comparator-200-入土为安的第九天

关键代码

pthread_t thread[FLAG_LEN];
    char differences[FLAG_LEN] = {0, 9, -9, -1, 13, -13, -4, -11, -9, -1, -7, 6, -13, 13, 3, 9, -13, -11, 6, -7};
    char *arguments[20];
    for (i = 0; i < FLAG_LEN; i++) {
        arguments[i] = (char *)malloc(3*sizeof(char));
        arguments[i][0] = first_letter;
        arguments[i][1] = differences[i];
        arguments[i][2] = user_string[i];
        pthread_create((pthread_t*)(thread+i), NULL, checking, arguments[i]);
    }
 int initialization_number;
    int i;
    char generated_string[FLAG_LEN + 1];
    generated_string[FLAG_LEN] = '\0';
    while ((initialization_number = random()) >= 64);
    
    int first_letter;
    first_letter = (initialization_number % 26) + 97

生成第一个字母:通过随机数生成一个字母 first_letter,范围在小写字母 az 之间。

#include <iostream>
using namespace std;
int main()
{
    char differences[20] = {0, 9, -9, -1, 13, -13, -4, -11, -9, -1, -7, 6, -13, 13, 3, 9, -13, -11, 6, -7};
    int just_a_string[20] = {115, 116, 114, 97, 110, 103, 101, 95, 115, 116, 114, 105, 110, 103, 95, 105, 116, 95, 105, 115};
    char a[100]={0};
    for(int i=0;i<20;i++)
    {
        a[i]=0^(108+differences[i]);
        cout <<a[i];
    }
    
    
    return 0;
}

lucky_hacker_you_are

目录
相关文章
|
6月前
|
Java
面试官:你知道Comparable 和 Comparator 的区别吗?我:巴拉巴拉
面试官:你知道Comparable 和 Comparator 的区别吗?我:巴拉巴拉
43 1
|
C++
【PAT甲级 - C++题解】1024 Palindromic Number
【PAT甲级 - C++题解】1024 Palindromic Number
43 0
|
C++
【PAT甲级 - C++题解】1155 Heap Paths
【PAT甲级 - C++题解】1155 Heap Paths
67 0
|
人工智能 文件存储 C++
【PAT甲级 - C++题解】1019 General Palindromic Number
【PAT甲级 - C++题解】1019 General Palindromic Number
73 0
|
人工智能 C++
【PAT甲级 - C++题解】1136 A Delayed Palin
【PAT甲级 - C++题解】1136 A Delayed Palin
83 0
|
存储 C++ 容器
【PAT甲级 - C++题解】1121 Damn Single
【PAT甲级 - C++题解】1121 Damn Single
80 0
|
C++ 容器
【PAT甲级 - C++题解】1144 The Missing Number
【PAT甲级 - C++题解】1144 The Missing Number
62 0
|
C++
【PAT甲级 - C++题解】1119 Pre- and Post-order Traversals
【PAT甲级 - C++题解】1119 Pre- and Post-order Traversals
77 0
|
存储 C++
【PAT甲级 - C++题解】1028 List Sorting
【PAT甲级 - C++题解】1028 List Sorting
77 0
|
人工智能
Educational Codeforces Round 113 (Rated for Div. 2) B. Chess Tournament(思维 构造)
Educational Codeforces Round 113 (Rated for Div. 2) B. Chess Tournament(思维 构造)
89 0