我是C#的新手,正在try 解决以下问题:
Write a program in C# to find the sum of all elements of the array. Go to the editor
Test Data:Input the number of elements to be stored in the array: 3 Input 3 elements in the array: element - 0: 2 element - 1: 5 element - 2: 8
预期输出:
Sum of all elements stored in the array is: 15
以下是我想出的解决方案:
Console.Write("Enter the length of the array : ");
int len = Convert.ToInt32 (Console.ReadLine());
int[] arr = new int[len];
for (int i = 0; i < len; i++) {
arr[i] = Convert.ToInt32(Console.Read());
}
Console.WriteLine(arr.Sum());
But I am getting the following outputs:
有人能告诉我我做错了什么吗?