fork download
  1. def makeRowSeq(row: Int) =
  2. for (col <- 1 to 10) yield {
  3.  
  4. val prod = (row * col).toString
  5.  
  6. val padding = " " * (4 - prod.length)
  7.  
  8. padding + prod
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. }
  16. // 以字串形式返回一行乘法表
  17.  
  18. def makeRow(row: Int) = makeRowSeq(row).mkString
  19. // 以字串形式返回乘法表,每行记录占一行字串
  20. def multiTable() = {
  21. val tableSeq = // 行记录字串的序列
  22. for (row <- 1 to 10)
  23.  
  24. yield makeRow(row)
  25.  
  26. tableSeq.mkString("\n")
  27. }
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:1: error: expected class or object definition
def  makeRowSeq(row: Int) =
^
Main.scala:18: error: expected class or object definition
def  makeRow(row: Int) =  makeRowSeq(row).mkString
^
Main.scala:20: error: expected class or object definition
def multiTable() =  {
^
three errors found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty