using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int N = 45;
for (int i = 0; i < N; i++)
{
Console.WriteLine("Я молодец!");
}
}
}
}
Объяснение:
Основной код вот:
int N = 45; // Кол-во раз
for (int i = 0; i < N; i++)
{
Console.WriteLine("Я молодец!");
}
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}");
}
}
}
// PascalABC.NET 3.0, сборка 1150 от 22.01.2016
begin
Writeln(ArrRandom(10,1,99).Println.Where(x->x mod 2=0).Average)
end.
Тестовое решение:
96 42 79 85 16 22 50 62 54 40
47.75
"Школьный подход" (видимо, короткому решению у нас не учат)
// PascalABC.NET 3.0, сборка 1150 от 22.01.2016
const
n=10;
var
a:array[1..n] of integer;
i,k,s:integer;
begin
s:=0;
k:=0;
Randomize;
for i:=1 to n do begin
a[i]:=Random(99)+1;
Write(a[i],' ');
if a[i] mod 2 = 0 then begin
s:=s+a[i];
Inc(k)
end
end;
Writeln;
Writeln(s/k)
end.
Тестовое решение:
22 22 58 41 54 80 71 65 47 99
47.2