Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

1180 - Lowest Number and Position C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
namespace ConsoleApp5
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var SizeOfArray=Convert.ToInt32(Console.ReadLine());
            string[] ValueOfArray = Console.ReadLine().Split(' ');
            
            int[] newArr = new int[SizeOfArray];
            for (int i = 0; i < ValueOfArray.Length; i++)
            {
                newArr[i] = int.Parse(ValueOfArray[i]);
            }
            int MinN=110;
            int IndexOfNumber=0;
            for(int i = 1; i <= SizeOfArray; i++)
            {
                if (MinN > newArr[i-1])
                {
                    MinN = newArr[i-1];
                    IndexOfNumber = i-1;
                }
            }
            Console.WriteLine($"Menor valor: {MinN}");
            Console.WriteLine($"Posicao: {IndexOfNumber}");
        }
    }
}
Source by www.beecrowd.com.br #
 
PREVIOUS NEXT
Tagged: #Lowest #Number #Position
ADD COMMENT
Topic
Name
4+6 =