finish ex6, tested

好长