스터디카페에서 쓸 프로그램임 

공부시간이 75시간 이상이면 7점

50이상 75미만이면 6점

25이상 50미만이면 5점

그 이하면 0점

여기에 가산점 개념이 있는데, 음식 호불호 설문조사 했을경우 1점이 추가됨


일단 출력물부터



2,3번째 당첨자는 확률이 너무 낮아서 그런지 0으로 나옴 



아래는 엑셀로 정리한것과

txt(UTF-8) 파일로 변환 한것임




코드는 여기


#= 개발언어: Julia v1.7.3 이벤트 기획/제작: 시너지플레이스 산곡점 총무 최근 업데이트일: 2022/07/02 =# using Dates using Random mutable struct Entrant name::String number::String p1::Int64 p2::Int64 accumPoint::Int64 checkFlag::Int64 end function descriptApp() println("=== 시너지플레이스 산곡점 이벤트 추첨프로그램 ===") end function workTimer() global tarTime = floor(DateTime(Y, M, D, H, MIN, SEC), Dates.Second(1)) printTimer() end function printTimer() while true curTime = Dates.now() timeLeft = floor(tarTime - curTime, Dates.Second(1)) println("남은 시간: $timeLeft") sleep(Dates.Second(1)) if timeLeft <= Dates.Second(1) print(M, "월 ", D, "일 ", H, "시 ", MIN, "분 ") println("추첨을 시작합니다.") break end end end function openFile() # 이름, 번호, 입실시간, 추가포인트가 탭(TAB)으로 구성된 파일 fileName = normpath("./Julia/entry_list.txt") f_entryList = open(fileName, "r") try global nOfEntrant = 30 global entryList = Vector{Entrant}(undef, nOfEntrant) n = 1 while !(eof(f_entryList)) line = readline(f_entryList) line = split(line, "\t") entrant = Entrant("", "", 0, 0, 0, 0) entrant.name = line[1] entrant.number = line[2] entrant.p1 = parse(Int64, line[3]) entrant.p2 = parse(Int64, line[4]) entryList[n] = entrant n = n + 1 end finally close(f_entryList) end end function processData() i = 1 while i <= nOfEntrant if entryList[i].p1 >= 75 entryList[i].p1 = 7 elseif entryList[i].p1 >= 50 entryList[i].p1 = 6 elseif entryList[i].p1 >= 25 entryList[i].p1 = 5 else entryList[i].p1 = 0 end entryList[i].accumPoint = entryList[i].p1 + entryList[i].p2 entryList[i].p2 = entryList[i].p1 + entryList[i].p2 if i != 1 entryList[i].accumPoint += entryList[i-1].accumPoint end if i != nOfEntrant i += 1 else break end end sumOfPoint = entryList[nOfEntrant].accumPoint rng = randperm(MersenneTwister(), sumOfPoint) counter = 0 i = 0 for pick in rng while (i != nOfEntrant) if (counter >= 3) break end i += 1 if entryList[i].checkFlag == 0 if (i == 1) && (pick <= entryList[i].accumPoint) entryList[i].checkFlag = 1 counter += 1 print("$counter 번째 당첨자: ", entryList[i].name, "/", entryList[i].number, ", ") println("당첨확률: ", ceil(entryList[i].p1 / sumOfPoint, digits=3) * 100, "%") elseif (i != 1) && (pick > entryList[i-1].accumPoint) && (pick <= entryList[i].accumPoint) entryList[i].checkFlag = 1 counter += 1 print("$counter 번째 당첨자: ", entryList[i].name, "/", entryList[i].number, ", ") println("당첨확률: ", ceil(entryList[i].p1 / sumOfPoint, digits=3) * 100, "%") end end end i = 0 end end const Y = 2022 const M = 7 const D = 2 const H = 11 const MIN = 31 const SEC = 0 descriptApp() workTimer() openFile() processData()


능력자 있으면 조언이나 수정코드주면 ㄳ