17 תשובות
שואל השאלה:
^^ זה מהchat gpt כן?
^^ זה מהchat gpt כן?
אנונימית
אז תכווני אותו
פחות או יותר
פחות או יותר
^^ כן, אבל לי יש את הגרסה בכסף ככה שהוא יותר מדויק. את רוצה שאני אבקש ממנו לעשות את זה פשוט יותר?
שואל השאלה:
^ כן אם אפשר זה יעזור
^ כן אם אפשר זה יעזור
אנונימית
אפשר גם ברגיל לא צריך להתרברב
ככה זה בסדר?
using system;
class simplevalidpassword
{
static void main()
{
string password;
bool isvalid;
console.writeline("enter a valid password:");
do
{
password = console.readline();
isvalid = isvalid(password);
if (!isvalid)
{
console.writeline("invalid. enter a valid password:");
}
} while (!isvalid);
console.writeline("valid password!");
}
static bool isvalid(string p)
{
bool u = false, l = false, d = false;
if (p.length < 6) return false;
foreach (char c in p)
{
if (char.isupper(c)) u = true;
else if (char.islower(c)) l = true;
else if (char.isdigit(c)) d = true;
if (u && l && d) return true;
}
return false;
}
}
using system;
class simplevalidpassword
{
static void main()
{
string password;
bool isvalid;
console.writeline("enter a valid password:");
do
{
password = console.readline();
isvalid = isvalid(password);
if (!isvalid)
{
console.writeline("invalid. enter a valid password:");
}
} while (!isvalid);
console.writeline("valid password!");
}
static bool isvalid(string p)
{
bool u = false, l = false, d = false;
if (p.length < 6) return false;
foreach (char c in p)
{
if (char.isupper(c)) u = true;
else if (char.islower(c)) l = true;
else if (char.isdigit(c)) d = true;
if (u && l && d) return true;
}
return false;
}
}
שואל השאלה:
^^
זה ל להתרברב המורה שלי בודק את זה ואני בטוחה שהוא ידע שהעתקתי..
^^
זה ל להתרברב המורה שלי בודק את זה ואני בטוחה שהוא ידע שהעתקתי..
אנונימית
לא דיברתי עם שואלת השאלה
שואל השאלה:
^^
chat gpt לא עוזר לי בכלל זה נותן לי דברים שבכלל לא למדנו
^^
chat gpt לא עוזר לי בכלל זה נותן לי דברים שבכלל לא למדנו
אנונימית
using system;
using system.text.regularexpressions;
namespace validpassword
{
class program
{
static void main(string[] args)
{
string inputpassword;
bool isvalidpassword;
console.writeline("please enter a valid password:");
do
{
inputpassword = console.readline();
isvalidpassword = isvalidpassword(inputpassword);
if (!isvalidpassword)
{
console.writeline("invalid password. please enter a valid password:");
}
} while (!isvalidpassword);
console.writeline("valid password entered!");
}
public static bool isvalidpassword(string password)
{
if (password.length < 6)
{
return false;
}
bool hasupper = false, haslower = false, hasdigit = false;
foreach (char c in password)
{
if (char.isupper(c))
{
hasupper = true;
}
else if (char.islower(c))
{
haslower = true;
}
else if (char.isdigit(c))
{
hasdigit = true;
}
if (hasupper && haslower && hasdigit)
{
return true;
}
}
return false;
}
}
}
using system.text.regularexpressions;
namespace validpassword
{
class program
{
static void main(string[] args)
{
string inputpassword;
bool isvalidpassword;
console.writeline("please enter a valid password:");
do
{
inputpassword = console.readline();
isvalidpassword = isvalidpassword(inputpassword);
if (!isvalidpassword)
{
console.writeline("invalid password. please enter a valid password:");
}
} while (!isvalidpassword);
console.writeline("valid password entered!");
}
public static bool isvalidpassword(string password)
{
if (password.length < 6)
{
return false;
}
bool hasupper = false, haslower = false, hasdigit = false;
foreach (char c in password)
{
if (char.isupper(c))
{
hasupper = true;
}
else if (char.islower(c))
{
haslower = true;
}
else if (char.isdigit(c))
{
hasdigit = true;
}
if (hasupper && haslower && hasdigit)
{
return true;
}
}
return false;
}
}
}
תשאלי את chat gpt
^ מה הקשר להתרברב? רק ציינתי שיש לי גרסא מדויקת יותר.
שואל השאלה:
^^^ עשיתי את כל המבחנים האלה אבל אני צריכה שאם זה לא נכון זה יגיד שוב לעשות סיסמה עד שהיא נכונה, איך עושים את זה?
^^^ עשיתי את כל המבחנים האלה אבל אני צריכה שאם זה לא נכון זה יגיד שוב לעשות סיסמה עד שהיא נכונה, איך עושים את זה?
אנונימית
בלולאת while
תעשי 4 פונקציות שהן הבדיקות שלך, ותעבירי את המחרוזת דרך שלושתן. רק אם זה עובר את 4 המבחנים, זה תקין.
מבחן 1 - password.length >= 6 מאוד פשוט
מבחן 2 - אפשר להמיר תוים למספרים, אז תרוצי על המחרוזת בלולאה ותבדקי שקיים תו שהוא בין a ל z
מבחן 3 - כמו למעלה אבל עם a z
מבחן 4 - אותו דבר אבל עם '0' ו- '9'
מבחן 1 - password.length >= 6 מאוד פשוט
מבחן 2 - אפשר להמיר תוים למספרים, אז תרוצי על המחרוזת בלולאה ותבדקי שקיים תו שהוא בין a ל z
מבחן 3 - כמו למעלה אבל עם a z
מבחן 4 - אותו דבר אבל עם '0' ו- '9'
למדת על פעולות על מחרוזות?
string password;
bool validpassword = false, hasupper = false, haslower = false, hasdigit = false;
while(!validpassword)
{
console.writeline ("enter password: ");
password = console.readline();
if (password.length >= 6)
{
for(int i = 0; i < password.length; i++)
{
char ch = password[i];
if (ch >= 'a' && ch <= 'z')
hasupper = true;
else if(ch >= 'a' && ch <= 'z')
haslower = true;
else if(ch >= '1' && ch <= '9')
hasdigit = true;
}
}
else
{
console.writeline("password length should be more than 6");
continue;
}
if (hasupper && haslower && hasdigit)
{
console.writeline("valid password");
validpassword = true;
}
else
{
console.writeline("invalid password");
}
bool validpassword = false, hasupper = false, haslower = false, hasdigit = false;
while(!validpassword)
{
console.writeline ("enter password: ");
password = console.readline();
if (password.length >= 6)
{
for(int i = 0; i < password.length; i++)
{
char ch = password[i];
if (ch >= 'a' && ch <= 'z')
hasupper = true;
else if(ch >= 'a' && ch <= 'z')
haslower = true;
else if(ch >= '1' && ch <= '9')
hasdigit = true;
}
}
else
{
console.writeline("password length should be more than 6");
continue;
}
if (hasupper && haslower && hasdigit)
{
console.writeline("valid password");
validpassword = true;
}
else
{
console.writeline("invalid password");
}
באותו הנושא: