首页 > 解决方案 > 如何使用数组计算模式。我只是编程的初学者。它用于我们的决赛项目

问题描述

我无法在我的代码上获得准确的结果以获取模式。它基于用户的输入。有人可以帮忙吗?这是我工作了好几天的代码

    string[] ArrModeInput = new string[20];
    //USER INPUT
    Console.WriteLine("Please Enter 20 Numbers ");
    //TO INPUT
    for (int stats = 0; stats < ArrModeInput.Length; stats++)
    {
        ArrModeInput[stats] = Console.ReadLine();
    }

    //CONDITION 
    for (int stats = 0; stats < ArrModeInput.Length; stats++)
    {
        //ArrModeInput[stats] = Console.ReadLine();
        int Count = 0;
        for (int m = 0; m < ArrModeInput.Length; m++)
            if (ArrModeInput[stats] == ArrModeInput[m])
                Count = Count + 1;
        Console.WriteLine("\t\n Mode is " + ArrModeInput[stats] + ". It ocuurs " + Count + " times");
    }

标签: c#

解决方案


推荐阅读