1)
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(num % 2 == 0 ? "Чётное" : "Нечётное");
Console.WriteLine(num / 10 + num % 10);
}
}
}
2)
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
double[] seconds = new double[8];
string[] athletes = new string[8];
double sum = 0;
double maxN = 0;
int max = 0;
for (int i = 0; i < 8; i++)
{
Console.WriteLine($"Введите фамилию {i + 1}-го участника и его результат: ");
athletes[i] = Console.ReadLine();
seconds[i] = Convert.ToDouble(Console.ReadLine());
sum += seconds[i];
if (seconds[i] > maxN)
{
maxN = seconds[i];
max = i;
}
}
Console.WriteLine($"\n\nСредний результат участников - {sum / 8}");
Console.WriteLine($"Лучший результат у участника с фамилией {athletes[max]} - {maxN}");
}
}
}
1)
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(num % 2 == 0 ? "Чётное" : "Нечётное");
Console.WriteLine(num / 10 + num % 10);
}
}
}
2)
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
double[] seconds = new double[8];
string[] athletes = new string[8];
double sum = 0;
double maxN = 0;
int max = 0;
for (int i = 0; i < 8; i++)
{
Console.WriteLine($"Введите фамилию {i + 1}-го участника и его результат: ");
athletes[i] = Console.ReadLine();
seconds[i] = Convert.ToDouble(Console.ReadLine());
sum += seconds[i];
if (seconds[i] > maxN)
{
maxN = seconds[i];
max = i;
}
}
Console.WriteLine($"\n\nСредний результат участников - {sum / 8}");
Console.WriteLine($"Лучший результат у участника с фамилией {athletes[max]} - {maxN}");
}
}
}
Модуль сделаем с функцией проверки на чётность чисел.
Основную программу почти не менял - см. комментарии
Объяснение:
в модуле есть функция getChet которой передаётся число, и на после проверки возвращает чётное это число или нет
модуль
unit pr1u;
interface
function getChet(i:integer):boolean;
implementation
function getChet(i:integer):boolean;
begin
getChet := i mod 2 = 0;
end;
begin
end.
основная программа
program pr1;
(*добавляем модуль pr1u для использования в программе*)
uses crt, pr1u ;
var
a:array[1..100]of integer;
i,p,p0,p1,sum,temp,n,j:integer;
begin
clrscr;
write('n=');
read(n);
for i:=1 to n do begin
write('a[',i,']=');
read(a[i]);
end;
writeln;
p:=1;
for i:=1 to n do
(* тут идёт использование функции getChat из модуля pr1u, которая проверяет отправленное ей число на чётность*)
if getChet(i) then p:=p*a[i];
writeln('proizvedenie=',p);
writeln;
for i:=n downto 1 do
if a[i]=0 then p0:=i;
writeln('pervyi 0 v pozicii - ',p0);
writeln;
for i:=1 to n do
if a[i]=0 then p1:=i;
writeln('poslednii 0 v posicii - ',p1);
writeln;
sum:=0;
for i:=p0 to p1 do
sum:=sum+a[i];
writeln('summa=',sum);
writeln;
readkey;
end.