Решил вот так, но бот не хочет воспринимать.
using System;
using System.Collections.Generic;
namespace MillionExercises
{
class Program
{
static void Main()
{
List<double[]> points = new List<double[]>();
double sumLength = 0;
for (int i = 0; i < 5; i++)
{
points.Add(Array.ConvertAll(Console.ReadLine().Split(), double.Parse));
}
sumLength += AddToLength(points[0], points[2]);
sumLength += AddToLength(points[0], points[3]);
sumLength += AddToLength(points[1], points[3]);
sumLength += AddToLength(points[1], points[4]);
sumLength += AddToLength(points[2], points[4]);
Console.WriteLine("{0:f3}", sumLength);
double AddToLength(double[] point1, double[] point2)
{
double sum;
sum = Math.Sqrt(Math.Pow(point2[0] - point1[0], 2) + Math.Pow(point2[1] - point1[1], 2));
return sum;
}
}
}
}
Бот число проверяет как строку?
Вывод Console.WriteLine("{0:f4}", square) и Console.WriteLine("{0:N4}",square) дают разные результаты, хотя по факту, и там и там число.
int count = int.Parse(Console.ReadLine());
int[] array = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int min = array[0];
int max = array[0];
int minIndex = 0;
int maxIndex = 0;
for (int i = 0; i < count; i++)
{
if (array[i] > max)
{
max = array[i];
maxIndex = i;
}
else if (array[i] < min)
{
min = array[i];
minIndex = i;
}
}
array[minIndex] = max;
array[maxIndex] = min;
for (int i = 0; i < count; i++)
{
Console.Write(array[i] + " ");
}
Console.WriteLine();
Да, либо в условии ошибка, либо в боте. Работает именно с xi < N;
string[] xN = Console.ReadLine().Split(' ');
int x = Int32.Parse(xN[0]);
int N = Int32.Parse(xN[1]);
int i = 1;
int num = 0;
while (Math.Pow(x, i) < N)
{
num += (Int32)Math.Pow(x, i);
i++;
}
Console.WriteLine(num);
string line = Console.ReadLine();
int sum = 0;
int i = 0;
while (i < line.Length)
{
sum += Int32.Parse(line.Substring(i, 1));
i++;
}
Console.WriteLine(sum);
string num = Console.ReadLine();
num = num.TrimStart('0');
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
int count = 0;
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < num.Length; j++)
{
if (Int32.Parse(num.Substring(j, 1)) == arr[i])
{
count += 1;
}
}
}
Console.WriteLine(count);
int num = Int32.Parse(Console.ReadLine());
int count = 0;
string line = "";
while (count < num)
{
line += ":)";
count++;
}
Console.WriteLine(line);
int num = Int32.Parse(Console.ReadLine());
if (num % 2 == 0 && (num > 0 && num < 100))
Console.WriteLine("YES");
else
Console.WriteLine("NO");
string[] line = (Console.ReadLine().Split(' '));
int sum = 0;
int i = 0;
while (i < line.Length)
{
if (Int32.Parse(line[i]) > 0)
{
sum += Int32.Parse(line[i]);
}
i++;
}
Console.WriteLine(sum);
string line = Console.ReadLine();
int at = line.IndexOf("(") + 1;
int wordLength = line.IndexOf(")") - at;
Console.WriteLine(line.Substring(at, wordLength));