Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Lister(m: Int) {
- private def toList(m: Int): List[Int] = {
- var k = m
- var l: List[Int] = Nil
- while (k > 0) {
- l = k :: l
- k -= 1
- }
- if (m % 2 != 0) {
- l
- } else {
- l.reverse
- }
- }
- override def toString: String = {
- var l = toList(m)
- var s = ""
- while (l != Nil) {
- if (s != "") {
- s += "-"
- }
- s += l.head
- l = l.tail
- }
- s
- }
- }
- object App {
- def main(v: Array[String]) {
- val c = v.length
- var i = c
- while (i > 0) {
- val m = Integer.parseInt(v(c - i))
- var j = 1
- while (j <= m) {
- val l = new Lister(j)
- println(l)
- j += 1
- }
- i -= 1
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement