#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;
}
為什麼這樣
您的答案為: This password is ACCEPTABL ...略 正確答案為: This password is WEAK
#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