.NET Framework 3.0 以上,支持LinQ
1,2,3,4,5,2,1,9
统计各字符出现次数,语言不限,
程序代码
using System.Collections;
int[] scores = new int[] { 97, 92, 81, 60 };
for (int i = 0; i < scores.Length; i++) {
int localNum=scores.GetValue(i);
IEnumerable<int> query =
from score in scores
where score = localNum
select score;
int scoreCount = query.Count();
Response.Write(scoreCount.toString());
}
int[] scores = new int[] { 97, 92, 81, 60 };
for (int i = 0; i < scores.Length; i++) {
int localNum=scores.GetValue(i);
IEnumerable<int> query =
from score in scores
where score = localNum
select score;
int scoreCount = query.Count();
Response.Write(scoreCount.toString());
}