#Find the indices of a vector x for which x>10. if x=c(3,12,4,17) you should report the vector as your answer
{#function
n=length(x)
if (n==0)
{
big.loc=Null
}else{#else
for(i in 1:n)
{
if(x[i]>10)
{
big.loc.index=big.loc.index+1
big.loc[big.loc.index]=i
}
}
}#else
if(big.loc.index>0)
{
big.loc=big.loc[1:big.loc.index]
}else{
big.loc=null
}
print(big.loc)
}#function
a1(c(10,12,13,2))
No comments:
Post a Comment