package com.uu.bigdata.scala.howework
object Work {
def main(args: Array[String]): Unit ={
var st ="what is my name what is my name what is my name what"
var st1 = st.split(" ")
var st2 = st1.foldLeft(Map[String,Int]())((x,y)=> x+(y ->(x.getOrElse(y,0)+1)))
st2.foreach(x=>println(x._1+"有"+x._2+"个"))
var sr ="jdkjfksklfjdlkjflksdjfkldsjflkdsjflds"
var sr1 = sr.foldLeft(Map[Char, Int]())((x, y)=> x +(y ->(x.getOrElse(y,0)+1)))
sr1.foreach(x =>println(x._1 +"有"+ x._2+"个"))}}
2给工资列添加值
package com.uu.bigdata.scala.howework
object Work2 {
def main(args: Array[String]): Unit ={
var a1 =("张三",3000)
var a2 =("李四",2000)
var a3 =("王五",4000)
var a4 =("赵柳",3100)
val list = List[Tuple2[String,Int]](a1,a2,a3,a4)println(list)
var list1 = list.map(x=>(x._1,(x._2*1.1).toInt))println(list1)}}
1.统计 一句话中的单词个数与一串字母中字母出现的个数package com.uu.bigdata.scala.howeworkobject Work { def main(args: Array[String]): Unit = { var st = "what is my name what is my name what is my name what" var...