在阵列中运行时重复复制 [英] Eleminate Duplicate At Runtime In Arrays

查看:58
本文介绍了在阵列中运行时重复复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此项目中,当我在运行时输入重复数字...我想显示输入另一个没有重复的数字.....



In this Project When I enter Duplicate Numbers at RunTime...I want to show Enter Another Number Without Duplicates.....

static int Read(int[]arr)
        {
             int First = arr[0];
        int Second = arr[0];
        int third = arr[0];
            for (int i = 0; i < arr.Length; i++)
            {

                Console.Write("The Enterd "+i.ToString() +":");
                arr[i] = int.Parse(Console.ReadLine());

                if (arr[i] > First)
                {
                    First = arr[i];
                }
            }

            for (int j = 0; j < arr.Length; j++)
            {
                if (arr[j] > Second && First > arr[j])
                {
                    Second = arr[j];
                }
            }

            for (int k = 0; k < arr.Length; k++)
            {
                if (arr[k] > third && Second > arr[k])
                {
                    third = arr[k];
                }
            }

            return third;


        }

static void Main(string[] args)
        {
            int[] v = new int[5];
            Console.WriteLine(Read(v));
        }
    }
}

推荐答案

算法非常简单:

The algorithm is very simple here:
  1. 让用户插入一个值。
  2. 验证用户输入的值:如果它已存在于数组中,则将错误通知给用户并转到1. / li>
  3. 在数组中插入用户输入的值
  4. 转到1,直到数组完全填满。


First总之,你没有指明你的问题。请更具体,并在下次提供更多详细信息。



其次, Google [ ^ ]。
First of all, you did not specify your problem. Please, be more specific and provide more details next time.

Secondly, there are tons of answers on Google[^].


这篇关于在阵列中运行时重复复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆