選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

59 行
1013B

  1. interface Source
  2. method next() as word
  3. end interface
  4. class Counter implements Source
  5. private word value
  6. private word[4] seen
  7. public method init(start as word)
  8. self.value = start
  9. end method
  10. public method next() as word
  11. self.value = self.value + 1
  12. return self.value
  13. end method
  14. public method twice() as Counter
  15. return self
  16. end method
  17. public method fill(n as word)
  18. var i as word
  19. for i = 0 to 3 step 1
  20. seen[i] = self.next()
  21. end for
  22. for i = 3 to 0 step -1
  23. if seen[i] = 0
  24. return
  25. else
  26. if i > n and not (i = 2)
  27. seen[i] = seen[i - 1]
  28. end if
  29. end if
  30. end for
  31. while value < n
  32. value = value + 1
  33. end while
  34. end method
  35. end class
  36. program Main
  37. var c as Counter
  38. var s as Source
  39. var w as word
  40. c = new Counter((1 + 2) * 3)
  41. c.fill(c.next())
  42. c.twice().twice().fill(w)
  43. s = c
  44. w = s.next()
  45. print "done"
  46. print 'x'
  47. print true
  48. print w
  49. if s <> null
  50. delete s
  51. end if
  52. end program

Powered by TurnKey Linux.