我的计划需要:
一个.生成一个由0到9的20个随机整数的数组.搜索数字7的第一个匹配项(如果有),并在数组中报告其位置.
湾 重复计算部分a 1000次,并对数组中的每个位置报告数组中第一次出现7的位置在该位置的次数
但是每当我运行程序时,我都会得到奇怪的结果(每次都不同),例如:
有谁知道我的程序有什么问题?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Week_6_Project_2
{
class Program
{
static int intArrayLength = 20;
static int[] resultsArray = new int[intArrayLength];
public static Array generateRandomArray() {
int[] randomNumberArray = new int[intArrayLength];
Random random = new Random();
int popcounter = 0;
while (popcounter < intArrayLength) {
randomNumberArray[popcounter] = random.Next(0, 10);
popcounter += 1;
}
return randomNumberArray;
}
public static void searchForSevens()
{
int counter = …Run Code Online (Sandbox Code Playgroud)