is.symmetirc=TRUE
j=n
for (i in 1:n)
{#for
if(x[i]!=x[(n+1)-i])
{
is.symmmetric=FALSE
break
}
}#for
# Find the vector x is symmetric. The example x vector in the previous problem is not symmetric, but x=c(5,7,2,7,5) is symmetric
last.i=n%/%2
is.symmetric=TRUE
for (i in 1:last.i )
{#for
if(x[i]!=x[(n+1)-i])
{
is.symmmetric=FALSE
break
}
}#for
No comments:
Post a Comment