????

B3843 [GESP202306 三级] 密码合规

prg_equal_depressed @ 2024-05-13 21:02:21

#include <iostream>
#include <fstream> 
using namespace std;
int n,m,a[1005],x[1005];
bool f;
int main(){
    //freopen("B3842.in","r",stdin);
    //freopen("B3842.out","w",stdout);
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        cin>>a[i];
        x[a[i]]++;
    }
    for (int i=0;i<n;i++){
        if (x[i]==0){
            cout<<i<<" ";f=1;
        }
    }
    if (!f) cout<<n;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

没找出来错哪了,可能来个大佬指教一下QWQ


by PRew_ @ 2024-05-13 21:05:16

@prg_equal_depressed 让你输出合规密码,你输出个 n rp--


by prg_equal_depressed @ 2024-05-13 21:06:23


by prg_equal_depressed @ 2024-05-13 21:06:34

不是这个,发错了


by prg_equal_depressed @ 2024-05-13 21:06:49

#include <iostream>
#include <string>
#include <cstring>
#include <fstream> 
using namespace std;
int k,s;
string a,x,q;
bool sf,af,lf,nf,f;
int main(){
    freopen("B3842.in","r",stdin);
    freopen("B3842.out","w",stdout);
    cin>>a;
    a+=',';
    for (int i=0;i<a.size();i++){
        if (a[i]==','){
            if (s>=6&&s<=12&&sf&&!f&&k>=2) cout<<x<<endl;
            s=0;sf=0;k=0;f=0;af=0;lf=0;nf=0;x=q;
        }
        else{
            s++;x+=a[i];
            if (a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$') sf=1;
            else if (a[i]>='A'&&a[i]<='Z'){
                if (!af) af=1;k++;
            }
            else if (a[i]>='a'&&a[i]<='z'){
                if (!lf) lf=1;k++;
            }
            else if (a[i]>='0'&&a[i]<='9'){
                if (!nf) nf=1;k++;
            }
            else f=1;
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

by PRew_ @ 2024-05-13 21:07:37

@prg_equal_depressed 我感觉你交错题了,或者说,你根本没读题,让你判断,却没有一个

if(/*条件*/) { /*代码*/}

你是如何做到的??????


by prg_equal_depressed @ 2024-05-13 21:07:42

切水题被倒切了QAQ


by PRew_ @ 2024-05-13 21:12:11

@prg_equal_depressed 我的做法

#include <iostream>
#include <string>
using namespace std;

bool isValidPassword(const string &password) {
    if (password.size() < 6 || password.size() > 12)
        return false;

    bool lower = false, upper = false, digit = false, special = false;

    for (char ch : password) {
        if (islower(ch))
            lower = true;
        else if (isupper(ch))
            upper = true;
        else if (isdigit(ch))
            digit = true;
        else if (ch == '!' || ch == '@' || ch == '#' || ch == '$')
            special = true;
        else
            return false;
    }

    return (lower + upper + digit >= 2) && special;
}

int main() {
    string input;
    getline(cin, input);

    size_t pos = 0;
    while ((pos = input.find(',')) != string::npos) {
        string password = input.substr(0, pos);
        if (isValidPassword(password))
            cout << password << endl;
        input.erase(0, pos + 1);
    }
}

by prg_equal_depressed @ 2024-05-13 21:12:36

额,谢谢


by prg_equal_depressed @ 2024-05-13 21:12:57

不过能帮我找下我的代码错拿了吗QWQ


by PRew_ @ 2024-05-13 21:13:18

@prg_equal_depressed 5年级比我6年级nb,rp++了


| 下一页