using
System;
using
System.Collections.Generic;
public
class
GFG
{
static
bool
ischar(
char
x)
{
if
((x >=
'A'
&& x <=
'Z'
) ||
(x >=
'a'
&& x <=
'z'
))
{
return
true
;
}
return
false
;
}
static
bool
isnum(
char
x)
{
if
(x >=
'0'
&& x <=
'9'
)
return
true
;
return
false
;
}
static
void
findIdandDoMain(String S,
int
N)
{
String ID =
""
, Domain =
""
;
List<String> words =
new
List<String>();
String curr =
""
;
for
(
int
i = 0; i < N; i++)
{
if
(S[i] ==
' '
)
{
words.Add(curr);
curr =
""
;
}
else
{
if
(S[i] ==
'.'
)
{
if
(i + 1 == N || (i + 1 < N &&
S[i + 1] ==
' '
))
continue
;
}
curr += S[i];
}
}
if
(curr.Length > 0)
words.Add(curr);
foreach
(String ss
in
words)
{
if
(ss.Length == 10)
{
bool
flag =
false
;
for
(
int
j = 0; j <= 9; j++)
{
if
(j >= 5 && j < 9)
{
if
(isnum(ss[j]) ==
false
)
flag =
true
;
}
else
{
if
(ischar(ss[j]) ==
false
)
flag =
true
;
}
}
if
(!flag)
{
ID = ss;
}
}
if
(ss.Length > 2 && ss.Substring(0, 3).Equals(
"www"
) &&
ss.Substring(ss.Length - 3).Equals(
"com"
))
{
Domain = ss.Substring(4, ss.Length-4);
}
}
Console.Write(
"ID = "
+ ID +
"\n"
);
Console.Write(
"Domain = "
+ Domain);
}
public
static
void
Main(String[] args)
{
String S =
"We thank ABCDE1234F for visiting "
+
"us and buying products item AMZrr@!k. "
+
"For more offers, visit us at www.amazon.com"
;
int
N = S.Length;
findIdandDoMain(S, N);
}
}