這道題有多種算法
算法
static bool JudgeIntersectLink
{
Hashtable ht = new Hashtable();
Link curr
Link curr
//store all the elements of link
while (curr
{
ht[curr
curr
}
//check all the elements in link
while (curr
{
//if exists
if (ht[curr
{
return true;
}
curr
}
return false;
}
算法
注意
static bool JudgeIntersectLink
{
bool exists = false;
Link curr
Link curr
//goto the end of the link
while (curr
{
curr
}
//join these two links
curr
//iterate link
while (curr
{
if (curr
{
exists = true;
break;
}
curr
}
//recover original status
curr
return exists;
}
算法
static bool JudgeIntersectLink
{
Link curr
Link curr
//goto the end of the link
while (curr
{
curr
}
//goto the end of the link
while (curr
{
curr
}
if (curr
return false;
else
return true;
}
From:http://tw.wingwit.com/Article/program/sjjg/201405/30738.html