如何使用C#生成OpenSTV选举的.BLT文件?

栏目: ASP.NET · 发布时间: 7年前

内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/2233695/how-do-i-generate-blt-files-for-openstv-elections-using-c

查看最新的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


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Mastering JavaServer Faces

Mastering JavaServer Faces

Bill Dudney、Jonathan Lehr、Bill Willis、LeRoy Mattingly / Wiley / 2004-6-7 / USD 40.00

Harness the power of JavaServer Faces to create your own server-side user interfaces for the Web This innovative book arms you with the tools to utilize JavaServer Faces (JSF), a new standard that wi......一起来看看 《Mastering JavaServer Faces》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具