我正在研究经常更新的动态分数列表.最终,这用于产生总体评级,因此需要删除较旧的条目(基于某些参数,而不是时间)以防止对整体进行重度+/-加权.它将从单独的枚举中一次添加多个值.
List<int> scoreList = new List<int>();
foreach(Item x in Items)
{
scoreList.Add(x.score);
}
//what I need help with:
if(scoreList.Count() > (Items.Count() * 3))
{
//I need to remove the last set (first in, first out) of values size
//Items.Count() from the list
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助它将非常感激:)我不得不使代码有点通用,因为它写得相当密码(没有编写方法).
我正在使用.NET GeoCoordinate类编写一个函数.我们有一个Airport类和一个City类,它们都定义了自己的类GeoCoordinate.
我需要选择最近的机场相对于城市,我正在尝试使用该GetDistanceTo()方法.
我现在拥有的内容如下:
Airport a = Airports.GetAllActiveAirports().Min(this.Coordinates.GetDistanceTo(n.Profile.Coordinates));
Run Code Online (Sandbox Code Playgroud)
另一个(工作)功能,按距离检索最近的机场列表:
List<Airports> airports = Airports.GetAllActiveAirports();
var nearby =
from a in airports
where this.Coordinates.GetDistanceTo(a.Profile.Coordinates) > d
select a;
foreach(Airport a in nearby)
{
airports.Remove(a);
}
Run Code Online (Sandbox Code Playgroud)
我已经看过使用LINQ和lambdas在一行中做这样的事情的例子,但我不完全确定如何执行这个...任何指针?
我正在做一些自学成才的Java,但似乎无法弄清楚这个循环中的问题:
问题是找到两个整数n1和n2的最大公约数,其中d是较小的值.方法是递减d直到GCD或它达到1 ...这是我到目前为止的地方:
Scanner input = new Scanner(System.in);
System.out.println("Please enter two integers: ");
int n1 = input.nextInt();
int n2 = input.nextInt();
int d = 0;
int temp = 0;
//finds the lowest value
if(n1 < n2) {
temp = n1;
n1 = n2;
n2 = temp;
}
for(d = n1;(n1 % d !=0 && n2 % d != 0);d--) {
}
System.out.println("The GCD of " + n1 + " and " + n2 + " is " + d);
Run Code Online (Sandbox Code Playgroud)
有什么指针吗?
我正在尝试使用MySQL数据库来处理我的网站的PC部件列表,从长远来看,这对我来说更容易......直到我需要进行一些文本搜索,这一切都很顺利.
这就是我所在的地方:
database name: _staff
table name: parts
Run Code Online (Sandbox Code Playgroud)
我需要 SELECT * FROM itemName MATCH ("Processors:%");
基本上我需要找到此表中itemName列以"处理器:"开头的所有行
字符串是冒号分隔的名称,前面是[category]:....如果有任何用途:)
想法?