比如有20个句子,该句子有三个属性
一个值记录句子出现的顺序,一个值为句子内容,另一个为句子权值。
按照权值大小选取 比如10个权值最大的句子,然后按照句子原来的循序输出这10个句子的内容。
该如何操作呢?
一个值记录句子出现的顺序,一个值为句子内容,另一个为句子权值。
按照权值大小选取 比如10个权值最大的句子,然后按照句子原来的循序输出这10个句子的内容。
该如何操作呢?
解决方案 »
- DataGridView 合并单元格
- MemoryStream stream = new MemoryStream(b, true);
- 求高手 谁能教我怎么让 一个窗体透明啊 ??
- event和委托!!!!!!!!!!!!!!!!!!!
- socket接发数据的多线程问题
- 200分征集.net开发的基于WinForm的商品化软件试用版下载
- 高手进来看下。分布式软件
- 哪位大侠知道msn的插件是怎么作的,或者相关的资料连接,谢了
- winform reportViewer报表~求高手指点~急求
- 读取一个字符串时,遇到空格就让他转到下一行。怎么写?
- C#realplayer控件问题
- C#如何判断是否安装了.net Framwork?
var maxWeightList = (from sentence in sentences orderby sentence.Weight descending select sentence).Take(5); var finalList = (from sentence in maxWeightList orderby sentence.Index select sentence.Content); foreach (var sentenceContent in finalList)
{
Console.WriteLine(sentenceContent);
}
{
public static int CurrentIndex = 0;
public int Weight;
public readonly int Index;
public string Content;
public Sentence()
{
Index = CurrentIndex++;
}
}
我有一个想法 //先定义一个句子的哈希表
hashtable sentences =new hashtable();
//句子的添加函数
public void tianjia(string content,int weight)
{ string con =content;int w=weight;
sentence s=new sentence(string con,int w);
int index=s.getIndex();//得到句子的序列号
sentences.add(index,s);
}
然后在根据,哈希表中的value值进行 排序啊 提取句子啊
这只是我的一个想法,也不知道行不行,反正是很麻烦很麻烦。
有没有简单一点的方法啊
我有一个想法 //先定义一个句子的哈希表
hashtable sentences =new hashtable();
//句子的添加函数
public void tianjia(string content,int weight)
{ string con =content;int w=weight;
sentence s=new sentence(string con,int w);
int index=s.getIndex();//得到句子的序列号
sentences.add(index,s);
}
然后在根据,哈希表中的value(句子对象)值进行 排序啊 提取句子啊
这只是我的一个想法,也不知道行不行,反正是很麻烦很麻烦。
有没有简单一点的方法啊
List<Sentence> sentences = new List<Sentence>(){new Sentence(){Content = "1,3",Weight=3},
new Sentence(){Content = "2,7",Weight=7},
new Sentence(){Content = "3,8",Weight=8},
new Sentence(){Content = "4,4",Weight=4},
new Sentence(){Content = "5,2",Weight=2},
new Sentence(){Content = "6,9",Weight=9},
new Sentence(){Content = "7,1",Weight=1},
new Sentence(){Content = "8,10",Weight=10},
new Sentence(){Content = "9,5",Weight=5},
new Sentence(){Content = "10,6",Weight=6},
};