Using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace СиШарп { class Program { static void Main(string[] args) { Console.Write("N = "); int N = int.Parse(Console.ReadLine()); Console.Write("A({0}):",N); double[] A = new double[N]; int Max = 1, Min = 1; Random RND = new Random(); for (int i = 0; i < N; i++) { A[i] = RND.NextDouble() * N; Console.Write(" {0:0.0}",A[i]); if (A[i] > A[Max]) Max = i; if (A[i] < A[Min]) Min = i; } Console.WriteLine("\nMin(A) = {0:0.0}[{1}]",A[Min],Min+1); Console.WriteLine("Max(A) = {0:0.0}[{1}]", A[Max], Max+1); Console.ReadKey(); } } }
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace СиШарп
{
class Program
{
static void Main(string[] args)
{
Console.Write("N = ");
int N = int.Parse(Console.ReadLine());
Console.Write("A({0}):",N);
double[] A = new double[N];
int Max = 1, Min = 1;
Random RND = new Random();
for (int i = 0; i < N; i++)
{
A[i] = RND.NextDouble() * N;
Console.Write(" {0:0.0}",A[i]);
if (A[i] > A[Max]) Max = i;
if (A[i] < A[Min]) Min = i;
}
Console.WriteLine("\nMin(A) = {0:0.0}[{1}]",A[Min],Min+1);
Console.WriteLine("Max(A) = {0:0.0}[{1}]", A[Max], Max+1);
Console.ReadKey();
}
}
}
N = 13
A(13): 11,0 9,2 4,5 12,0 2,5 11,1 9,6 10,4 0,2 10,2 6,7 0,4 10,0
Min(A) = 0,2[9]
Max(A) = 12,0[4]