我已经编写了一段代码,但是它有错误,我无法弄清楚如何修复它们,因为我还是编程新手。
static public int prodtab(int[] base1)
{
int output = 1;
for (int i = 0; i < base1.Length; i++)
{
output *= base1[i];
}
return output;
}
static public void annuletab(int[] base1, int pos1, int pos2)
{
base1 = base1.Where((nimporte, i) => i < pos1 || i > pos2).ToArray();
}
static void Main(string[] args)
{
Console.WriteLine("Entrez la premiere position");
position1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Entrez la deuxieme position");
position2 = Convert.ToInt32(Console.ReadLine());
int[] newvec = annuletab(vec, position1, position2);
有人能说出错误是什么吗?
答案 0 :(得分:3)
欢迎编程!
由于书面annuletab
没有返回任何内容。试试这个:
static public int[] annuletab(int[] base1, int pos1, int pos2)
{
var base2 = base1.Where((nimporte, i) => i < pos1 || i > pos2).ToArray();
return base2;
}