var couser = -1 class Student{ var id:Int var name:String var scores = [Int]() var telphone:String } class StudentManager{ var origin = Student() var info:Student{ set{ origin.name = NewValue.name origin.id = NewValue.id origin.scores = NewValue.scores origin.telphone = NewValue.telphone students += [origin] } } var students = [Student]() var avg = [Double]() var callAvg:avg{ get{ avg = [] for cnt in 0 ... couser{ avg.append = Double(students[cnt][2].reduce(0,+))/3.0 } return avg } } } func inputInfo(id:Int,name:String,score:[Int],telphone:String)->String{ couser += 1; var manager = StudentManager() let input = manager.info manager.info = Student(id:id,name:name,scores:score,telphone:telphone) return "완료"; } func sayList()->(){ var manager = StudentManager() let sortScore = manager.students var score = sortScore.sorted(by:{$0[0]<$1[0]}) let avgScore = manager.callAvg print("학번\t이름\t전화\t국어\t수학\t영어\t평균") for cnt in 0...couser{ print("\(score[cnt][0])\t\(score[cnt][1])\t\(score[cnt][3])",terminator:"\t") print("\(score[cnt][2][0]),\t\(score[cnt][2][1]),\t\(score[cnt][2][2])\t\(avgScore)") } } func avgList()->(){ var manager = StudentManager() var avgScore = manager.callAvg avgScore = avgScore.sorted(by:>) sortIndex = [Int]() var avgCnt = -1 var score = manager.students var onOff = 0 for cnt1:Int in 0...couser{//지금 보고있는 avgIndex for cnt2:Int in 0...couser{//scoreIndex let avgTmp = Double(score[cnt2][2].reduce(0,+))/3.0 //scoreAvg if(avgTmp == avgScore[cnt1]){ if(!sortIndex.isEmpty){ onOff = 0; for cnt3:Int in 0...avgCnt{ if(cnt2 == sortIndex[cnt3]){ onOff = 1 break } } if(onOff<1){//넣어야해 avgCnt += 1 sortIndex[avgCnt] = cnt2 break } } else{ avgCnt += 1 sortIndex[avgCnt] = cnt2 break } } } } print("학번\t이름\t전화\t국어\t수학\t영어\t평균") for cnt in 0...couser{ let sort = sortIndex[cnt] print("\(score[sort][0])\t\(score[sort][1])\t\(score[sort][3])",terminator:"\t") print("\(score[sort][2][0]),\t\(score[sort][2][1]),\t\(score[sort][2][2])\t\(avgScore[cnt])") } } func modInfo(id:Int)->String{ let manager = StudentManager() var score = manager.Students for cnt in 0...couser{ if(score[cnt][0] == id){ let avg = Double(score[cnt][2][0]+score[cnt][2][1]+score[cnt][2][2])/3.0 print("이름:\(score[cnt][1]) 전화: \(score[cnt][3])",terminator:"\t") print("국어: \(score[cnt][2][0]), 수학: \(score[cnt][2][1]), 영어: \(score[cnt][2][2]), 평균: \(avg)") return "" } } return "아이디 없음" } func removeInfo(id:Int)->String{ let manager = StudentManager() var score = manager.Students for cnt in 0...couser{ couser -= 1 return "완료" } return "아이디 없음" } print("학생 성적 관리 프로그램") var onOff = 1 var select = 0; while(onOff>0){ print("1.학생 정보 입력\n2.학생 리스트 보기\n3.평균순 성적 보기\n4.학생 정보 수정력\n5.학생 정보 삭제\n6.종료\n입력 :",terminator:" "); select = Int((readLine())!)! if(select>0 && select <7){ switch(select){ case 1: let id = Int(readLine()!)! let name = readLine() let kor = Int(readLine()!)! let math = Int(readLine()!)! let eng = Int(readLine()!)! let telphone = readLine() let arr = [Int]() arr.append(kor) arr.append(math) arr.append(eng) print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") case 2: sayList() case 3: avgList() case 4: let id = Int(readLine()!)! print("\(modInfo(id:id))") case 5: let id = Int(readLine()!)! print("\(removeInfo(id:id))") default://종료 onOff = 0 } } else{ print("잘못된 입력. 재입력"); } } print("종료");
Standard input is empty
prog.swift:12:3: error: variable with a setter must also have a getter set{ ^ prog.swift:10:15: error: 'Student' cannot be constructed because it has no accessible initializers var origin = Student() ^ prog.swift:22:14: error: use of undeclared type 'avg' var callAvg:avg{ ^~~ prog.swift:2:7: error: class 'Student' has no initializers class Student{ ^ prog.swift:3:6: note: stored property 'id' without initial value prevents synthesized initializers var id:Int ^ = 0 prog.swift:4:6: note: stored property 'name' without initial value prevents synthesized initializers var name:String ^ = "" prog.swift:6:6: note: stored property 'telphone' without initial value prevents synthesized initializers var telphone:String ^ = "" prog.swift:13:18: error: use of unresolved identifier 'NewValue'; did you mean 'newValue'? origin.name = NewValue.name ^~~~~~~~ newValue prog.swift:12:3: note: 'newValue' declared here set{ ^ prog.swift:14:16: error: use of unresolved identifier 'NewValue'; did you mean 'newValue'? origin.id = NewValue.id ^~~~~~~~ newValue prog.swift:12:3: note: 'newValue' declared here set{ ^ prog.swift:15:20: error: use of unresolved identifier 'NewValue'; did you mean 'newValue'? origin.scores = NewValue.scores ^~~~~~~~ newValue prog.swift:12:3: note: 'newValue' declared here set{ ^ prog.swift:16:22: error: use of unresolved identifier 'NewValue'; did you mean 'newValue'? origin.telphone = NewValue.telphone ^~~~~~~~ newValue prog.swift:12:3: note: 'newValue' declared here set{ ^ prog.swift:26:16: error: cannot assign to value: 'append' returns immutable value avg.append = Double(students[cnt][2].reduce(0,+))/3.0 ~~~~~~~~~~ ^ prog.swift:37:17: error: 'Student' cannot be constructed because it has no accessible initializers manager.info = Student(id:id,name:name,scores:score,telphone:telphone) ^ prog.swift:44:35: error: type 'Student' has no subscript members var score = sortScore.sorted(by:{$0[0]<$1[0]}) ^~ prog.swift:56:2: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? sortIndex = [Int]() ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:62:29: error: type 'Student' has no subscript members let avgTmp = Double(score[cnt2][2].reduce(0,+))/3.0 //scoreAvg ~~~~~^~~~~~ prog.swift:64:9: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? if(!sortIndex.isEmpty){ ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:67:18: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? if(cnt2 == sortIndex[cnt3]){ ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:74:7: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? sortIndex[avgCnt] = cnt2 ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:80:6: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? sortIndex[avgCnt] = cnt2 ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:89:14: error: use of unresolved identifier 'sortIndex'; did you mean 'SetIndex'? let sort = sortIndex[cnt] ^~~~~~~~~ SetIndex Swift.SetIndex:1:18: note: 'SetIndex' declared here public typealias SetIndex<Element> = Set<Element>.Index ^ prog.swift:96:14: error: value of type 'StudentManager' has no member 'Students' var score = manager.Students ^~~~~~~ ~~~~~~~~ prog.swift:109:14: error: value of type 'StudentManager' has no member 'Students' var score = manager.Students ^~~~~~~ ~~~~~~~~ prog.swift:123:24: error: expected ',' separator if(select>0 && select <7){ ^ , prog.swift:123:24: error: '<' is not a prefix unary operator if(select>0 && select <7){ ^ prog.swift:133:5: error: cannot use mutating member on immutable value: 'arr' is a 'let' constant arr.append(kor) ^~~ prog.swift:132:5: note: change 'let' to 'var' to make it mutable let arr = [Int]() ^~~ var prog.swift:134:5: error: cannot use mutating member on immutable value: 'arr' is a 'let' constant arr.append(math) ^~~ prog.swift:132:5: note: change 'let' to 'var' to make it mutable let arr = [Int]() ^~~ var prog.swift:135:5: error: cannot use mutating member on immutable value: 'arr' is a 'let' constant arr.append(eng) ^~~ prog.swift:132:5: note: change 'let' to 'var' to make it mutable let arr = [Int]() ^~~ var prog.swift:136:35: error: value of optional type 'String?' must be unwrapped to a value of type 'String' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ prog.swift:136:35: note: coalesce using '??' to provide a default when the optional value contains 'nil' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ ?? <#default value#> prog.swift:136:35: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ ! prog.swift:136:59: error: value of optional type 'String?' must be unwrapped to a value of type 'String' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ prog.swift:136:59: note: coalesce using '??' to provide a default when the optional value contains 'nil' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ ?? <#default value#> prog.swift:136:59: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' print("\(inputInfo(id:id,name:name,score:arr,telphone:telphone))") ^ ! <unknown>:0: error: error opening input file 'prog.o' (No such file or directory ) clang: error: no such file or directory: 'prog.o' clang: error: no such file or directory: '@prog.autolink'
Standard output is empty