编辑代码

func shuffleStudents(dict dictStudents : Dictionary<Int,String>) -> (key:Int?,value:String?)?{
    if dictStudents.isEmpty{
        return nil
    }else{
        var Numbers = [Int](dictStudents.keys)
        Numbers.shuffle()
        let c = Numbers[0]
        return (c,dictStudents[c])}}
var students:[Int:String] = [:]
students.updateValue("程瀚游",forKey:2020967016)
students.updateValue("王金玉",forKey:2020967007)
students.updateValue("吴长豪",forKey:2020967020)
students.updateValue("徐杨",forKey:2020967015)
students.updateValue("邹徐陈",forKey:2020967017)
if shuffleStudents(dict : students) == nil{
    print("nil")
    }else{
    if let h = shuffleStudents(dict : students){
        print("请学号:\(h.key!) \(h.value!)同学回答问题!")}}