Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

334 46 955470 劉泰廣-第二階段 #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions 南山gmail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <iostream>
#include <string>
#include <locale>
using namespace std;

int main() {
string gmail, password, ending, number;
int a = 0, c = 0, d = 0, e = 0, f = 0;
bool b = true;
cin >> gmail;
number = gmail.substr(1, 6);
ending = gmail.substr(7);
for (int i=0 ; i<6; i++){
if ('0'<=number[i] && number[i]<='9'){
a++;
}
}
if (a!=6 || gmail[0]!='a' || ending!="@gmail.com") {
cout << "不符合格式,重打\n";
int a = 0;
cin >> gmail;
number = gmail.substr(1, 6);
ending = gmail.substr(7);
for (int i=0 ; i<6; i++){
if ('0'<=number[i] && number[i]<='9'){
a++;
}
}
a=0;
}
cout << "符合了,請輸入密碼\n";

cin >> password;
while(password.length()<8) {
cout << "失敗,因為長度太短,請重新輸入密碼\n";
cin >> password;
}
for (int k=0; k<password.size(); k++){
if (ispunct(password[k]))
c++;
if (isupper(password[k]))
d++;
if (islower(password[k]))
e++;
if (isdigit(password[k]))
f++;
}
if (c+d+e+f == password.size() && c!=0 && d!=0 && e!=0 && f!=0)
cout << "好樣的,密碼強度是強@@\n";
else
cout << "密碼太弱囉,不過你開心就好\n";
}