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]
public class Test
{
public static int change(int x){return -x;}
public static void Main()
{
const int n=5;
int[,] a=new int[n,n];
Random rnd=new Random();
Console.Write("введите число:");
int c=int.Parse(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("исходный массив:");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
a[i,j]=rnd.Next(1,10);
Console.Write(a[i,j]);
}
Console.WriteLine("");
}
Console.WriteLine("полученный массив:");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i,j]==c) a[i,j]=change(c);
Console.Write(a[i,j]);
}
Console.WriteLine("");
}
}
}