//Поскольку не указан данный массив, то заполню его случайными числами
using System;
namespace ConsoleApp2
{
class Program
static void Main(string[] args)
Random rand = new Random();
const int size = 10;
const int x = -100;
const int y = 100;
int counter = 0;
int[] arr = new int[size];
Console.WriteLine("Массив:");
for (int i = 0; i < size; i++)
arr[i] = rand.Next(x, y);
if (arr[i] < 0)
counter++;
Console.WriteLine((i + 1) + ") " + arr[i]);
}
Console.WriteLine("\nКоличество отрицательных элементов: " + counter);
Console.ReadKey();
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x, s: integer;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
x:=StrToInt(Edit1.Text);
s:=(x+2)/5;
Showmessage(IntTostr(s)+'ответ');
end.
//Поскольку не указан данный массив, то заполню его случайными числами
using System;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();
const int size = 10;
const int x = -100;
const int y = 100;
int counter = 0;
int[] arr = new int[size];
Console.WriteLine("Массив:");
for (int i = 0; i < size; i++)
{
arr[i] = rand.Next(x, y);
if (arr[i] < 0)
counter++;
Console.WriteLine((i + 1) + ") " + arr[i]);
}
Console.WriteLine("\nКоличество отрицательных элементов: " + counter);
Console.ReadKey();
}
}
}
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x, s: integer;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
x:=StrToInt(Edit1.Text);
s:=(x+2)/5;
Showmessage(IntTostr(s)+'ответ');
end;
end.