Let the user enter a mailbox and verify the legality of the entered mailbox.
Notes on the legality of the mailbox:
A. There is only one "@" sign.
B. At least one "." After the "@" sign But not more than two.
C. If there are two ".", two "." Can't be together.
D. Cannot start with "@" and cannot end with "@"
E. " @ "and". " Can't be together.
F. Cannot be "." At the beginning, cannot be "." End
Console.Write ("Please enter your e-mail:");
String k = Console.ReadLine ();
int a = K.indexof ("@");
int B = K.lastindexof ("@");
int c = K.indexof (".");
int d = K.lastindexof (".");
BOOL E = K.startswith ("@");
bool F = K.startswith (".");
BOOL G = K.endswith ("@");
bool h = K.endswith (".");
if (A = = B && C > a && c + 1! = d && e = False && F = = False && G = = False &am p;& h = = False)
{
if (c! = d)
{
String L = k.substring (c + 1, d-1);
bool m = L.contains (".");
if (M = = False)
{
Console.WriteLine ("The mailbox is formatted correctly! ");
}
Else
{
Console.WriteLine ("Mailbox format is wrong! ");
}
}
Console.WriteLine ("The mailbox is formatted correctly! ");
}
Else
{
Console.WriteLine ("Mailbox format is wrong! ");
}
Simple judgment of the mailbox format (some of which are not resolved)