c# - 如何使用数组计算模式。我只是编程的初学者。它用于我们的决赛项目
问题描述
我无法在我的代码上获得准确的结果以获取模式。它基于用户的输入。有人可以帮忙吗?这是我工作了好几天的代码
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 - C将值传递给matlab并从中获取结果
- javascript - 如何在聚焦文本输入字段的同时更改 div 的背景颜色?
- html - 不需要 - 移动视图中的空白 - 为什么会发生?
- reactjs - React live server 没有显示任何内容,只是显示选项卡继续加载
- python - 我正在尝试在 discord py 中扮演反应角色
- c++ - 在 C++ 中加速嵌套循环
- php - 为什么laravel停止显示更改一段时间后,我必须一次又一次地删除缓存文件,任何解决方案
- r - tidyr::pivot_longer 提出:错误:无法结合`TSPAN6`
和`MT-CO2` - android - 如何删除exoplayer中的当前媒体源?
- asp.net-core - ASP.NET Core 3.1 MVC 身份问题