多指數【難度:0級】:
答案1:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Skip(1).Where((x, i) => x % (i + 1) == 0).ToList();
}
}
答案2:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((v, i) => i != 0 && v % i == 0).ToList();
}
}
答案3:
using System;
using System.Linq;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((v, i) => i != 0 && v % i == 0).ToList();
}
}
答案4:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((x, i) => i != 0 && x % i == 0).ToList();
}
}
答案5:
using System;
using System.Linq;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((x, i) => i != 0 && x % i == 0).ToList();
}
}
答案6:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((x, i) => (i != 0 && x % i == 0)).ToList();
}
}
答案7:
using System;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
var list = new List<int>();
for(var i = 1; i < xs.Count; i++){
if(xs[i]%i == 0) list.Add(xs[i]);
}
return list;
}
}
答案8:
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
=> xs.Where((e,i)=> i > 0 && e%i == 0).ToList();
}
答案9:
using System;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
var finalList = new List<int>();
for(int i = 1; i < xs.Count; i++)
{
if(xs[i]%i == 0) finalList.Add(xs[i]);
}
return finalList;
}
}
答案10:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs
.Select((val, id) => new {val, id})
.Skip(1)
.Where(v => v.val % v.id == 0)
.Select(v => v.val)
.ToList();
}
}
答案11:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((t, i) => i > 0 && t % i == 0).ToList();
}
}
答案12:
using System;
using System.Linq;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
return xs.Where((t, i) => i > 0 && t % i == 0).ToList();
}
}
答案13:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs) => xs.Where((x, i) => i != 0 && x % i == 0).ToList();
}
答案14:
using System;
using System.Linq;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs) =>
xs.Where((x,i) => i != 0 && x % i == 0).ToList();
}
答案15:
using System;
using System.Collections.Generic;
public static class Kata
{
public static List<int> MultipleOfIndex(List<int> xs)
{
List<int> newLst = new List<int>();
for (int i = 1; i < xs.Count; i++)
{
if (xs[i] % i == 0)
newLst.Add(xs[i]);
}
return newLst;
}
}