Visual Basic, Array, Mod
I have 2 variables - Z and X. Z is a sequence of numbers and X is just a number. F.e. Z = 4 6 2 6 2 3 (it can be any length) and X = 2. I need to do operation Mod for each number - Z mod X: 4 Mod 2, 6 Mod 2开发者_开发知识库, 2 Mod 2,... And after that all numbers with Mod=0 must be written to new array. How to do this thing ?
assume z is an array and output is a list, so :
for i as integer = 0 to z.length-1
if z(i) mod x = 0
output.add(z(i)
end if
精彩评论