本文整理汇总了C#中Tuple.Last方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.Last方法的具体用法?C# Tuple.Last怎么用?C# Tuple.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.Last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public string Run()
{
BigInteger max = 0;
int maxIndex = 0;
for (int i = 2; i <= 1000; i++)
{
if (Math.Sqrt(i) % 1 == 0)
continue;
List<Tuple<BigInteger, BigInteger, BigInteger>> solutions = getPeriod(i);
BigInteger tempMax = 0;
if (solutions.Count % 2 == 0)
{
tempMax = (BigInteger)(solutions.Last().Item1 * solutions.Last().Item3 + solutions.Last().Item2);
}
else
{
solutions.Reverse();
Tuple<BigInteger, BigInteger, BigInteger>[] fractions = new Tuple<BigInteger, BigInteger, BigInteger>[solutions.Count];
fractions[0] = new Tuple<BigInteger, BigInteger, BigInteger>(1, solutions.ElementAt(0).Item3, 0);
for (int x = 1; x < fractions.Length; x++)
{
BigInteger numerator = (solutions.ElementAt(x).Item3 * fractions[x - 1].Item1) + (x > 1 ? fractions[x - 1].Item2 : 0);
fractions[x] = new Tuple<BigInteger, BigInteger, BigInteger>(numerator, fractions[x - 1].Item1, numerator + fractions[x - 1].Item1);
}
tempMax = (BigInteger)fractions.Last().Item3;
}
if (tempMax > max)
{
maxIndex = i;
max = tempMax;
}
}
return maxIndex.ToString();
}
示例2: LastTwoTuple
public void LastTwoTuple()
{
const int expected = 42;
var t = new Tuple<int, int>(1, 42);
int actual = t.Last();
Assert.AreEqual(expected, actual);
}