1 package com.zk02
 2 /*使用eclipse(或其他开发工具也可)创建工程(5分)
 3 2)遍历studentsList,输出上述内容(5分)
 4 3)创建girlList,boyList,lt18List,gt18List(5分)
 5 4)遍历studentsList,把所有男生存入boyList,女生存入girlList ,大于等于18岁的存入gt18List,小于18岁的存入lt18List (5分)
 6 5)并计算所有男生的平均年龄(5)
 7 注释完美(5分)
 8 使用eclipse(或其他开发工具也可)创建工程(5分)
 9 2)遍历studentsList,输出上述内容(5分)
10 3)创建girlList,boyList,lt18List,gt18List(5分)
11 4)遍历studentsList,把所有男生存入boyList,女生存入girlList ,大于等于18岁的存入gt18List,小于18岁的存入lt18List (5分)
12 5)并计算所有男生的平均年龄(5)
13 注释完美(5分)
14  */
15 import scala.collection.mutable.ListBuffer
16 
17 object ZhouKao {
18   def main(args: Array[String]): Unit = {
19     val studentsList = new ListBuffer[(String, String, Int)]()
20     val boyList = new ListBuffer[(String, String, Int)]()
21     val valueList = new ListBuffer[Int]()
22     studentsList.append(("张三", "男", 16))
23     studentsList.append(("李四", "男", 18))
24     for (item <- studentsList) {
25       println(s"姓名:${item._1}    性别:${item._2}  年龄${item._3} ")
26       if (item._2 == "男") {
27         boyList.append((item._1, item._2, item._3))
28       }
29 
30     }
31     boyList.foreach(println(_))
32 
33     boyList.foreach(line => {
34       valueList.append(line._3)
35     })
36     val total = valueList.reduce(_ + _)
37     val average = total / boyList.size
38     println(average)
39   }
40 
41 }