嗨,我必须编写一个程序来计算候选人的数量以及他们从最好到最差的投票数。我编写了两个不同的类来使用 fileInputStream 和另一个使用扫描仪类并将其存储在 arraylist 中,但是老师在文本文件中的方式是一些选票在不同的行上,所以他们会去就像在一条线上,而选票在另一条线上。所以它是这样的:
//this is how the text appears in the text file and I was wondering if I could get all
//the "votes" to look like the first one.
<v> 5 4 3 2 1
<v> 1 2 3 4 5
<v>
1
2
3
5
<v>
5
2
4
1
3