2014年面试题

  1. local count = 0
  2. local mode = 5
  3. function go(index,str,jk)
  4.   str = str ..(jk==0 and "" or jk)
  5.   if index <= 0 then
  6.     if string.sub(str,3,3) ~= "3" then
  7.       count = count + 1
  8.       print(str)
  9.     end
  10.     return
  11.   end
  12.   for i = 1,mode do
  13.     if not string.find(str,i) and jk+i~=6 then
  14.       go(index-1,str,i)
  15.     end
  16.   end
  17. end
  18. go(5,"",0)
  19. print(count)
posted @ 2016-01-20 10:52  dx2019  阅读(107)  评论(0编辑  收藏  举报