RE求条,九月认证快到了

B3843 [GESP202306 三级] 密码合规

Innate_Joker @ 2024-08-13 12:23:44

#include <cstring>
#include <iostream>
using namespace std;
int main() {
    char pinn[1000];
    cin.getline(pinn,1000);
    int len = strlen(pinn);
    for(int i = 0; i < len; i ++ ) {
        char pin[100];
        int j = i,lenn = 0;
        while(pinn[j] != ',') {
            pin[lenn ++ ] = pinn[j ++ ];
        }
        i = j;
        bool small = false;
        bool big = false;
        bool special = false;
        bool number = false;
        for(int p = 0; p < strlen(pin); p ++ ) {
            if(pin[p] == '!' || pin[p] == '@' ||
               pin[p] == '#' || pin[p] == '$') {
                special = true;
            }
            if(pin[p] >= 'a' && pin[p] <= 'z') {
                small = true;
            }
            if(pin[p] >= 'A' && pin[p] <= 'Z') {
                big = true;
            }
            if(pin[p] >= '0' && pin[p] <= '9') {
                number = true;
            }
        }
        short total = 0;
        if(small == true) {
            total ++;
        }
        if(big == true) {
            total ++;
        }
        if(number == true) {
            total ++;
        }
        if(special == true && total >= 2 && lenn >= 6 && lenn <= 12) {
            cout << pin << ' ' << special << ' ' << total << endl;
        }
    }
    return 0;
}

Error:

Runtime Error.
Received signal 11: Segmentation fault with invalid memory reference.

Chinese:

运行时出错。
接收到信号 11:分段故障,内存引用无效。

by lin20081016 @ 2024-08-13 12:35:50

最后一串密码后没有逗号,第11行再以逗号为判断就会卡住吧


by Fractured_Angel @ 2024-08-13 12:40:56

不知道这 GESP 到底有啥用。。。


by Maisie586_ @ 2024-08-13 12:41:47

@Fractured_Angel 可以免一关CSP((


by zts201210 @ 2024-08-13 12:42:52

@lin20081016 对

while(pinn[j] != ',' && j < len)

@Innate_Joker


by zts201210 @ 2024-08-13 12:43:49

@Maisie586_ 但是有点贵((


by Innate_Joker @ 2024-08-13 13:01:41

感谢。 此贴结。


|