#23506: why


winniehseu2835@gmail.com (肚子好餓給我吃的)

學校 : 大同大學
編號 : 120538
來源 : [115.43.67.94]
最後登入時間 :
2022-09-08 11:33:27
a624. 4. Password Analyzer -- HP CodeWars2007 | From: [111.71.120.152] | 發表日期 : 2020-11-24 13:08

#include <iostream>

#include <string>

using namespace std;

 

int main()

{

    string s;

    //cout<< 'A'-0 <<" "<<'Z'-0<<" " <<'a'-0 <<" " << 'z'-0;

    while(cin >> s){

        int big = 0,small = 0,ns = 0,level=0; //big:大寫 small:小寫 ns:數字或符號

        if(s.length() >= 8){//比較字串長度有沒有超過8

            level++;

        }

        for(int i = 0; i < s.length();i++){

            if(s[i]-0 >= 'A'-0 && s[i]-0 <='Z'-0){//看看有沒有大寫

                big++;

            }

            else if(s[i]-0 >= 'a'-0 && s[i]-0 <='z'-0){//看看有沒有小寫

                small++;

            }

            else{//如果不是大寫或小寫就是符號

                ns++;

            }

        }

        if(big > 0 && small > 0){

            level++;

        }

        if(ns > 0){

            level++;

        }

        if(level == 0){

            cout <<"This password is WEAK"<<endl;

        }

        if(level == 1){

            cout <<"This password is ACCEPTABLE"<<endl;

        }

        if(level == 2){

            cout <<"This password is GOOD"<<endl;

        }

        if(level == 3){

            cout <<"This password is STRONG"<<endl;

        }

    }

 

    return 0;

}

 

 

為什麼這樣

#0: 100% WA (line:2)

您的答案為: This password is ACCEPTABL ...略
正確答案為: This password is WEAK
 
#24155: Re:why


Easonsfriend (去寫./Problems?ownerid=89827)

學校 : 不指定學校
編號 : 89827
來源 : [106.105.188.90]
最後登入時間 :
2024-04-23 23:15:35
a624. 4. Password Analyzer -- HP CodeWars2007 | From: [106.105.188.90] | 發表日期 : 2021-01-23 18:22

#include

#include

using namespace std;

 

int main()

{

    string s;

    //cout<< 'A'-0 <<" "<<'Z'-0<<" " <<'a'-0 <<" " << 'z'-0;

    while(cin >> s){

        int big = 0,small = 0,ns = 0,level=0; //big:大寫 small:小寫 ns:數字或符號

        if(s.length() >= 8){//比較字串長度有沒有超過8

            level++;

        }

        for(int i = 0; i < s.length();i++){

            if(s[i]-0 >= 'A'-0 && s[i]-0 <='Z'-0){//看看有沒有大寫

                big++;

            }

            else if(s[i]-0 >= 'a'-0 && s[i]-0 <='z'-0){//看看有沒有小寫

                small++;

            }

            else{//如果不是大寫或小寫就是符號

                ns++;

            }

        }

        if(big > 0 && small > 0){

            level++;

        }

        if(ns > 0){

            level++;

        }

        if(level == 0){

            cout <<"This password is WEAK"<<endl;

        }

        if(level == 1){

            cout <<"This password is ACCEPTABLE"<<endl;

        }

        if(level == 2){

            cout <<"This password is GOOD"<<endl;

        }

        if(level == 3){

            cout <<"This password is STRONG"<<endl;

        }

    }

 

    return 0;

}

 

 

為什麼這樣

#0: 100% WA (line:2)

您的答案為: This password is ACCEPTABL ...略
正確答案為: This password is WEAK
  • 同時有字母及至少一個數字或符號 (如:"sPookyFiSH3" 或 "$PookyFI3H")

 

 
ZeroJudge Forum