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}");
}
}
}
1.
составной оператор - это скобки begin...end (в С образных языках для это используются реальные скобки {}) которые позволяют объединить несколько команд под одним оператором
if a > b then begin
с:=1;
d:=2;
end
else begin
c:=3;
d:=4;
end
2.
var
a,b,c,max:integer;
begin
writeln('Введите возраст призеров:');
readln(a,b,c);
if (a < b) and (a < c) then
begin
max := a;
writeln('Самый младший - первый призер, ему ',max,' лет.');
end;
if (b < a) and (b < c) then
begin
max := b;
writeln('Самый младший - второй призер, ему ',max,' лет.');
end;
if (c < a) and (c < b) then
begin
max := c;
writeln('Самый младший - третий призер, ему ',max,' лет.');
end;
end.