如何使用C#生成OpenSTV選舉的.BLT檔案?
檢視最新的SO部落格文章後,我剛剛下載了OpenSTV,關於主持人選舉的結果.傑夫寫道,他使用OpenSTV進行選舉,並提供了一個包含投票資料的選票檔案(.blt).
我的問題是:你如何在C#中建立一個.BLT檔案?
這裡有兩種方式,我可以想到投票頁:
>投票頁面將每個投票新增到SQL資料庫中,然後以某種方式將投票結果輸入到.BLT檔案中.怎麼樣我該怎麼做?
>或者,投票頁面建立該檔案,然後每次有人投票時新增該檔案.我相信這不是投票頁如何工作,因為它是完全不可擴充套件的,但是我怎麼能在C#中做到這一點?
我有興趣瞭解兩種可能性如何工作,以及如何在C#中做到這一點.提前致謝.哦,我希望傑夫看到這個問題,因為他可能會有一個很好的答案
BLT檔案格式的最佳解釋如下:
4 2# four candidates are competing for two seats -2# Bob has withdrawn (optional) 1 4 1 3 2 0# first ballot 1 2 4 1 3 0 1 1 4 2 3 0# The first number is the ballot weight (>= 1). 1 1 2 4 3 0# The last 0 is an end of ballot marker. 1 1 4 3 0# Numbers in between correspond to the candidates 1 3 2 4 1 0# on the ballot. 1 3 4 1 2 0 1 3 4 1 2 0# Chuck, Diane, Amy, Bob 1 4 3 2 0 1 2 3 4 1 0# last ballot 0# end of ballots marker "Amy"# candidate 1 "Bob"# candidate 2 "Chuck"# candidate 3 "Diane"# candidate 4 "Gardening Club Election"# title
我所做的一切都是
>在SQL Management Studio中執行臨時查詢以獲取投票結果
>將貼上的結果複製到文字檔案中(輸出是預設為製表符分隔的)
寫了一個小的50行C#應用程式,從查詢轉換成BLT格式
程式碼日誌版權宣告:
翻譯自:http://stackoverflow.com/questions/2233695/how-do-i-generate-blt-files-for-openstv-elections-using-c