Дата активности | Консольный раздел | Прогресс | ||
---|---|---|---|---|
2021-03-08 | book | 110. Функции | 13 % | |
2021-03-08 | book | 101. Математика | 115 % | |
2021-02-15 | book | 100. Массивы | 100 % | |
2021-02-07 | book | 011. Циклы | 100 % | |
2021-02-06 | book | 010. Условия | 100 % | |
2021-02-05 | book | 001. Числа | 100 % | |
2021-01-30 | book | 000. Строки | 100 % | |
2021-01-27 | task1 | Календарь | 94 % | |
2021-01-18 | task1 | Цифры | 92 % | |
2021-01-17 | task1 | Целые задачи | 100 % | |
2021-01-11 | task1 | Геометрия | 100 % | |
2021-01-10 | task1 | Символы | 100 % | |
2021-01-09 | task1 | Формулы | 100 % | |
2021-01-07 | task1 | Лирика | 93 % | |
2021-01-04 | task1 | Строки | 100 % | |
2020-12-31 | task1 | Целые числа | 100 % | |
2020-12-28 | task1 | Семантика | 100 % | |
Итого: | 95 % |
Робот Шарп засчитал ответ? Просто сделав тоже самое он мне выдает ошибку
public static int Min(int[] array)
{
int res_min = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[0] < array[i])
{
array[0] = array[0];
}
else
{
array[0] = array[i];
}
}
res_min = array[0];
return res_min;
}
public static int Max(int[] array)
{
int res_max = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[0] > array[i])
{
array[0] = array[0];
}
else
{
array[0] = array[i];
}
}
res_max = array[0];
return res_max;
}
static void Main(string[] args)
{
int a = Convert.ToInt32(Console.ReadLine());
string[] str = Console.ReadLine().Split();
int[] ar = new int[a];
for (int i = 0; i < a; i++)
{
ar[i] = Convert.ToInt32(str[i]);
}
int min = Min(ar);
int max = Max(ar);
Console.WriteLine(min + " " + max);
}
double a = Convert.ToDouble(Console.ReadLine());
double res = Math.PI * a * a;
Console.WriteLine("{0:0.0000}",res);
int a = Convert.ToInt32(Console.ReadLine());
string[] str = Console.ReadLine().Split();
int[] array = new int[a];
int[] array1 = new int[a];
for (int i = 0; i < a; i++)
{
array[i] = Convert.ToInt32(str[i]);
}
for (int i = 0; i < a; i++)
{
array1[i] = Convert.ToInt32(str[i]);
}
for (int i = 0; i < a; i++)
{
if (array[0] < array[i])
{
array[0] = array[0];
}
else
{
array[0] = array[i];
}
}
for (int i = 0; i < a; i++)
{
if (array1[0] > array1[i])
{
array1[0] = array1[0];
}
else
{
array1[0] = array1[i];
}
}
Console.WriteLine(array[0] + " " + array1[0]);
double t = 0.0;
double x = 3.000;
double y = 1.000;
Console.WriteLine("-------------------------");
Console.WriteLine("| t | x | y |");
Console.WriteLine("-------------------------");
for (double i = t; t <= 7.0; t = t + 0.1)
{
x = Math.Sin(3.0 * t) + 3.0 * Math.Cos(t);
y = Math.Cos(2.0 * t);
Console.WriteLine("| {0,3:f1} | {1,6:f3} | {2,6:f3} |", t, x, y);
}
Console.WriteLine("-------------------------");
В целом, та еще херня
double y = Convert.ToDouble(Console.ReadLine());
double z = 0;
double z_up = 0;
double z_down = 0;
for (double i = -0.5; i <= 0.5;)
{
z_up = 1 + Math.Pow(Math.Cos(i + y), 2.0);
z_down = 2 + Math.Abs(y - Math.Sin(i));
z = z_up / z_down;
Console.WriteLine("{0:0.00000}",z);
i = i + 0.1;
}
double N = Convert.ToDouble(Console.ReadLine());
double res = 0;
for (double i = 1; i <= N; i++)
{
res = Math.Sqrt(i + res);
}
Console.WriteLine("{0:0.00000}",res);
double a = Convert.ToDouble(Console.ReadLine());
double n = Math.Sqrt(6561);
for (int i = 0; i < a - 1; i++)
{
n = Math.Sqrt(n);
}
Console.WriteLine("{0:0.0000}",n);
double a = Convert.ToDouble(Console.ReadLine());
double x = Convert.ToDouble(Console.ReadLine());
double z = 0;
double z_up = Math.Pow(Math.Pow(x, 3), 0.25) + a * x;
double z_under = Math.Log(Math.Sqrt(a * a + Math.Sqrt(x)));
z = z_up / z_under;
Console.WriteLine("{0:0.0000}", z);
string[] str = Console.ReadLine().Split();
double a = Convert.ToInt32(str[0]);
double b = Convert.ToInt32(str[1]);
double c = Convert.ToInt32(str[2]);
double korn = 0;
double x1 = 0;
double x2 = 0;
double D = b * b - 4 * a * c;
if (D > 0)
{
korn = 2;
}
if (D < 0)
{
korn = 0;
}
if (D == 0)
{
korn = 1;
}
if (korn == 2)
{
x1 = (b * -1 + Math.Sqrt(D)) / (2 * a);
x2 = (b * -1 - Math.Sqrt(D)) / (2 * a);
if (x1 < x2)
{
Console.WriteLine("{0:0.000} {1:0.000}", x1, x2);
}
else
{
Console.WriteLine("{0:0.000} {1:0.000}",x2, x1);
}
}
if (korn == 1)
{
x1 = (b * -1 + Math.Sqrt(D)) / (2 * a);
Console.WriteLine("{0:0.000}", x1);
}
if (korn == 0)
{
Console.WriteLine("NO");
}
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
string[] res = new string[a];
int[] min = new int[a];
int[] max = new int[a];
int[] r = new int[a];
int minn = 0;
int maxx = 0;
for (int i = 0; i < str.Length; i++)
{
min[i] = Convert.ToInt32(str[i]);
max[i] = Convert.ToInt32(str[i]);
r[i] = Convert.ToInt32(str[i]);
}
for (int i = 0; i < str.Length; i++)
{
if (r[i] == 0)
{
minn = minn + 1;
}
}
Console.WriteLine(minn);
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
string[] res = new string[a];
int[] min = new int[a];
int[] max = new int[a];
int[] r = new int[a];
int minn = 0;
int maxx = 0;
for (int i = 0; i < str.Length; i++)
{
min[i] = Convert.ToInt32(str[i]);
max[i] = Convert.ToInt32(str[i]);
r[i] = Convert.ToInt32(str[i]);
}
for (int i = 1; i < str.Length; i++)
{
if (min[0] < min[i])
{
min[0] = min[0];
}
if (min[0] > min[i])
{
min[0] = min[i];
}
}
for (int i = 0; i < a; i++)
{
if (r[i] == min[0])
{
minn = i;
}
}//true
for (int i = 1; i < str.Length; i++)
{
if (max[0] > max[i])
{
max[0] = max[0];
}
else
{
max[0] = max[i];
}
}
for (int i = 0; i < a; i++)
{
if (r[i] == max[0])
{
maxx = i;
}
}
//true
for (int i = 0; i < a; i++)
{
res[i] = str[i];
if (i == minn)
{
res[minn] = str[maxx];
}
if (i == maxx)
{
res[maxx] = str[minn];
}
}
for (int i = 0; i < a; i++)
{
Console.Write(res[i] + " ");
}
Console.WriteLine();
Фууххх, как же долго я парился с этой задачей.... Зато решил полностью самостоятельно и на все 100 процентов!)))
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
int[] min = new int[a];
int[] max = new int[a];
for (int i = 0; i < str.Length; i++)
{
min[i] = Convert.ToInt32(str[i]);
max[i] = Convert.ToInt32(str[i]);
}
for (int i = 1; i < str.Length; i++)
{
if (min[0] < min[i])
{
min[0] = min[0];
}
else
{
min[0] = min[i];
}
}
for (int i = 1; i < str.Length; i++)
{
if (max[0] > max[i])
{
max[0] = max[0];
}
else
{
max[0] = max[i];
}
}
Console.WriteLine(min[0] + " " + max[0]);
Вот, теперь нормально решил
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
string min = "1000000000";
string min_r = "0";
string max = "-1000000000";
string max_r = "-1000000000";
for (int i = 1; i < str.Length; i++)
{
if (int.Parse(str[i - 1]) < int.Parse(str[i]))
{
min_r = min;
min = str[i - 1];
max_r = max;
max = str[i];
if (int.Parse(min_r) < int.Parse(min))
{
min = min_r;
}
if (int.Parse(max_r) > int.Parse(max))
{
max = max_r;
}
}
}
Console.WriteLine(min + " " + max);
Боже, как же я ступил. Я подумал, что в задаче говорится про четные/нечетные числа, а не индексы. Довольно долго провозился)))
что за херня с условием? Ок, допустим четные и нечетные были перепутаны местами, но 6(четное) умножить на два неравно 36
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
string[] s = new string[str.Length];
for (int i = 0; i < s.Length; i++)
{
s[i] = Convert.ToString(int.Parse(str[i]) + 1);
}
for (int i = 0; i < s.Length - 1; i++)
{
Console.Write(s[i] + ",");
}
Console.Write(s[a - 1] + ".");
Console.WriteLine();
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
for (int i = a - 1; i >= 0; i--)
{
Console.Write(str[i] + " ");
}
Console.WriteLine();
int a = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
int[] n = new int[a];
Console.WriteLine(str[0] + " " + str[a - 1]);
int a = int.Parse(Console.ReadLine());
int[] n = new int[a];
for (int i = 0; i < n.Length; i++)
{
n[i] = 1;
Console.WriteLine(n[i]);
}
string[] str = Console.ReadLine().Split();
long a = long.Parse(str[0]);
long b = long.Parse(str[1]);
long res = 0;
long aa = a;
long i = a;
while (i <= b && b >= a)
{
res = res + a;
a = a * aa;
i++;
}
Console.WriteLine(res);
long a = Convert.ToInt64(Console.ReadLine());
int kol = Convert.ToString(a).Length;
int i = 0;
while (i < kol)
{
i++;
}
if (i == 1)
{
Console.WriteLine(a);
}
if (i == 2)
{
Console.WriteLine((a / 10) + (a % 10));
}
if (i == 3)
{
Console.WriteLine((a / 100) + (a / 10 % 10) + (a % 10));
}
if (i == 4)
{
Console.WriteLine((a / 1000) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
if (i == 5)
{
Console.WriteLine((a / 10000) + (a / 1000 % 10) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
if (i == 6)
{
Console.WriteLine((a / 100000) + (a / 10000 % 10) + (a / 1000 % 10) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
if (i == 7)
{
Console.WriteLine((a / 1000000) + (a / 100000 % 10) + (a / 10000 % 10) + (a / 1000 % 10) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
if (i == 8)
{
Console.WriteLine((a / 10000000) + (a / 1000000 % 10) + (a / 100000 % 10) + (a / 10000 % 10) + (a / 1000 % 10) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
if (i == 9)
{
Console.WriteLine((a / 100000000) + (a / 10000000 % 10) + (a / 1000000 % 10) + (a / 100000 % 10) + (a / 10000 % 10) + (a / 1000 % 10) + (a / 100 % 10) + (a / 10 % 10) + (a % 10));
}
Пришлось все делать ручками, обидно :(
double a = double.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split();
double res = 0;
for (int i = 0; i < str.Length; i++)
{
res = res + Convert.ToDouble(str[i]);
}
Console.WriteLine("{0:0.0}",res / a);
long a = long.Parse(Console.ReadLine());
Console.WriteLine(Convert.ToString(a).Length);
int a = int.Parse(Console.ReadLine());
if (a % 2 == 0)
{
Console.WriteLine(a / 2);
}
if (a % 3 == 0 && a % 2 != 0)
{
Console.WriteLine(a / 3);
}
if (a % 5 == 0 && a % 2 != 0)
{
Console.WriteLine(a / 5);
}
if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0)
{
Console.WriteLine(1);
}
for (int i = 0; i < 10; i++)
{
break;
}
for (int i = 1; i < 100; i++)
{
if (i % 7 == 0)
{
Console.WriteLine(i);
}
else
{
continue;
}
}
ulong a = ulong.Parse(Console.ReadLine());
switch (a)
{
case 1: Console.WriteLine("понедельник"); break;
case 2: Console.WriteLine("вторник"); break;
case 3: Console.WriteLine("среда"); break;
case 4: Console.WriteLine("четверг"); break;
case 5: Console.WriteLine("пятница"); break;
case 6: Console.WriteLine("суббота"); break;
case 7: Console.WriteLine("воскресенье"); break;
}
ulong a = ulong.Parse(Console.ReadLine());
if (a % 2 == 0 && a < 100 && a > 9)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
string[] str = Console.ReadLine().Split();
long a = long.Parse(str[0]);
long b = long.Parse(str[1]);
long c = long.Parse(str[2]);
if (a < b && a < c)
{
Console.WriteLine(a);
if (b < c)
{
Console.WriteLine(b);
Console.WriteLine(c);
}
else
{
Console.WriteLine(c);
Console.WriteLine(b);
}
}
if (b < a && b < c)
{
Console.WriteLine(b);
if (a < c)
{
Console.WriteLine(a);
Console.WriteLine(c);
}
else
{
Console.WriteLine(c);
Console.WriteLine(a);
}
}
if (c < b && c < a)
{
Console.WriteLine(c);
if (b < a)
{
Console.WriteLine(b);
Console.WriteLine(a);
}
else
{
Console.WriteLine(a);
Console.WriteLine(b);
}
}
string[] str = Console.ReadLine().Split();
long a = long.Parse(str[0]);
long b = long.Parse(str[1]);
long c = long.Parse(str[2]);
long d = long.Parse(str[3]);
long one = a - b;
long two = b - c;
long three = c - d;
long four = d - a;
long on = 0;
long tw = 0;
if (one < 0)
{
one = one * -1;
}
if (two < 0)
{
two = two * -1;
}
if (three < 0)
{
three = three * -1;
}
if (four < 0)
{
four = four * -1;
}
if (one < two)
{
on = one;
}
else
{
on = two;
}
if (three < four)
{
tw = three;
}
else
{
tw = four;
}
if (on < tw)
{
Console.WriteLine(on);
}
else
{
Console.WriteLine(tw);
}
long a = long.Parse(Console.ReadLine());
if (a < 0)
{
Console.WriteLine(a * -1);
}
else
{
Console.WriteLine(a);
}
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
bool bo = true;
if (a > b)
{
Console.WriteLine(a);
}
else
{
Console.WriteLine(b);
}
int max = 0;
Console.WriteLine(a > b ? a : b);
int a = int.Parse(Console.ReadLine());
Console.WriteLine(a >> 2);
Console.WriteLine(a << 3);
string[] str = Console.ReadLine().Split();
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
Console.WriteLine(a + b);
Console.WriteLine(a - b);
Console.WriteLine(a * b);
Console.WriteLine(a / b);
Console.WriteLine(a % b);
Console.WriteLine("sbyte" + " " + sbyte.MinValue + " " + sbyte.MaxValue);
Console.WriteLine("byte" + " " + byte.MinValue + " " + byte.MaxValue);
Console.WriteLine("short" + " " + short.MinValue + " " + short.MaxValue);
Console.WriteLine("ushort" + " " + ushort.MinValue + " " + ushort.MaxValue);
Console.WriteLine("int" + " " + int.MinValue + " " + int.MaxValue);
Console.WriteLine("uint" + " " + uint.MinValue + " " + uint.MaxValue);
Console.WriteLine("long" + " " + long.MinValue + " " + long.MaxValue);
Console.WriteLine("ulong" + " " + ulong.MinValue + " " + ulong.MaxValue);
string str = Console.ReadLine();
string str1 = str.Trim('[');
str1 = str1.TrimStart(' ');
Console.WriteLine("[" + str1);
string str2 = str.TrimEnd(']');
str2 = str2.TrimEnd(' ');
Console.WriteLine(str2 + "]");
string str3 = str.Trim('[');
str3 = str3.Trim(']');
str3 = str3.Trim(' ');
Console.WriteLine("[" + str3 + "]");
string[] str = Console.ReadLine().Split();
string word = Console.ReadLine();
string[] res = new string[str.Length + 1];
for (int i = 2; i < res.Length; i++)
{
res[i] = str[i - 1];
}
res[0] = str[0];
res[1] = word;
for (int i = 0; i < res.Length; i++)
{
Console.Write(res[i] + " ");
}
Console.WriteLine();
string str = Console.ReadLine();
int a = str.IndexOf("(");
int b = str.IndexOf(")");
Console.WriteLine(str.Substring(a + 1, b - a - 1));
int year = int.Parse(Console.ReadLine());
DateTime data = new DateTime(year, 1, 2);
Console.WriteLine(data.AddDays(254).ToString("dd.MM.yyyy"));
int N = int.Parse(Console.ReadLine());
string[] names = new string[N];
DateTime[] borns = new DateTime[N];
TimeSpan[] array = new TimeSpan[N];
for (int i = 0; i < N; i++)
{
names[i] = Console.ReadLine();
borns[i] = DateTime.Parse(Console.ReadLine());
}
TimeSpan time = borns[0].Subtract(borns[1]).Duration();
string index = "";
string index1 = "";
for (int i = 0; i < N - 1; i++)
{
for (int j = i + 1; j < N; j++)
{
array[j] = borns[i].Subtract(borns[j]).Duration();
if (array[j].Ticks < time.Ticks)
{
time = array[j];
index = names[i];
index1 = names[j];
}
}
}
Console.WriteLine(index + " " + index1);
Наполовину сам, наполовину с решением из видео
Эххх....... Хочу какую-то математическую задачу, по типу задания про кур
DateTime date = DateTime.Parse(Console.ReadLine());
DateTime date1 = DateTime.Parse(Console.ReadLine());
TimeSpan a = date1.Subtract(date).Duration();
Console.WriteLine(a.TotalDays + " " + a.TotalHours + " " + a.TotalMinutes);
string str = Console.ReadLine();
string str1 = Console.ReadLine();
string str2 = Console.ReadLine();
string[] s = Console.ReadLine().Split();
int opl = int.Parse(s[0]);
int shtr = int.Parse(s[1]);
DateTime date = DateTime.Parse(str);
DateTime date1 = DateTime.Parse(str1);
DateTime date2 = DateTime.Parse(str2);
TimeSpan d_of_opl = date1.Subtract(date);
TimeSpan d_of_shtr = date2.Subtract(date1);
int dn_opl = Convert.ToInt32(d_of_opl.Days) + 1;
int dn_shtr = Convert.ToInt32(d_of_shtr.Days) + 1;
int res = dn_opl * opl - dn_shtr * shtr;
if (res > 0)
{
Console.WriteLine(res);
}
if (res <= 0)
{
Console.WriteLine("0");
}
решение на 100%, сделал полностью самостоятельно
string str = Console.ReadLine();
string[] s = Console.ReadLine().Split();
int year = int.Parse(s[0]);
int month = int.Parse(s[1]);
int day = int.Parse(s[2]);
int hour = int.Parse(s[3]);
int min = int.Parse(s[4]);
int sek = int.Parse(s[5]);
int msek = int.Parse(s[6]);
DateTime one = new DateTime(long.Parse(str));
DateTime two = new DateTime(year, month, day, hour, min, sek, msek);
Console.WriteLine(one.CompareTo(two));
Это первое задание из этой темы, которое я решил полностью самостоятельно)))
long a = Convert.ToInt64(Console.ReadLine());
long s = a % 60;
long m = a / 60;
long h = a / 3600;
if (h > 0)
{
m = m - h * 60;
}
if (h >= 24)
{
h = h - (h / 24) * 24;
}
Console.WriteLine(h + " " + m + " " + s);
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int res = 0;
for (int i = a; i < b; i++)
{
if (DateTime.IsLeapYear(i))
{
res = res + 1;
}
}
if (a == b)
{
if (DateTime.IsLeapYear(a))
{
res = res + 1;
}
}
Console.WriteLine(res);
string str = Console.ReadLine();
DateTime date;
if (DateTime.TryParse(str, out date))
{
date = DateTime.Parse(str);
Console.WriteLine(date.DayOfYear);
}
else
{
Console.WriteLine("-1");
}
DateTime min = DateTime.MinValue;
DateTime max = DateTime.MaxValue;
Console.WriteLine(min.ToString("G", System.Globalization.CultureInfo.CreateSpecificCulture("lv")));
Console.WriteLine(max.ToString("G", System.Globalization.CultureInfo.CreateSpecificCulture("lv")));
string str = Console.ReadLine();
long a = Convert.ToInt64(str);
string[] ch = new string[str.Length];
long[] chisla = new long[ch.Length];
int chet = 0;
int nechet = 0;
for (int i = 0; i < str.Length; i++)
{
ch[i] = Convert.ToString(str[i]);
}
for (int i = 0; i < str.Length; i++)
{
chisla[i] = Convert.ToInt64(ch[i]);
if (chisla[i] % 2 == 0)
{
chet = chet + 1;
}
else
{
nechet = nechet + 1;
}
}
if (chet > nechet)
{
Console.WriteLine(2);
}
if (chet < nechet)
{
Console.WriteLine(1);
}
if (chet == nechet)
{
Console.WriteLine(0);
}
Опять, к сожалению, всего на 55%
string str = Console.ReadLine();
int a = Convert.ToInt32(str);
int b1 = a / 100;
int b2 = a / 10 % 10;
int b3 = a % 10;
int c = b1 + b2 + b3;
int d1 = c / 10;
int d2 = c % 10;
int f = d1 + d2;
Console.WriteLine(Math.Min(a, f));
на 55% решение, зато свое)))
long a = Convert.ToInt64(Console.ReadLine());
long b6 = a / 100000;
long b5 = a / 10000 % 10;
long b4 = a / 1000 % 10;
long b3 = a / 100 % 10;
long b2 = a / 10 % 10;
long b1 = a % 10;
if (b6 + b5 + b4 == b3 + b2 + b1)
{
Console.WriteLine("Happy");
}
else
{
Console.WriteLine("Regular");
}
long a = Convert.ToInt64(Console.ReadLine());
long b1 = a / 1000;
long b2 = a / 100 % 10;
long b3 = a / 10 % 10;
long b4 = a % 10;
if (b4 != 0)
{
Console.WriteLine(b4 + "" + b2 + "" + b3 + "" + b1);
}
if (b4 == 0 && b3 != 0)
{
Console.WriteLine(b2 + "" + b3 + "" + b1);
}
if (b4 == 0 && b3 == 0 && b2 == 0)
{
Console.WriteLine(b1);
}
long a = Convert.ToInt64(Console.ReadLine());
long ed = a % 10;
long des = a / 10 % 10;
long res = a - ed - des * 10;
Console.WriteLine(res);
string[] str = Console.ReadLine().Split();
double h = Convert.ToInt32(str[0]);
double m = Convert.ToInt32(str[1]);
double gr_h = h * 30 + m / 2;
double gr_m = m * 6;
double res = Math.Abs(gr_m - gr_h);
double res1 = Math.Abs(gr_m - gr_h + 360);
double res2 = Math.Abs(gr_m - gr_h - 360);
double res3 = Math.Abs(gr_m - gr_h + 720);
double res4 = Math.Abs(gr_m - gr_h - 720);
double a = Math.Min(res, res1);
double answ = Math.Min(a, res2);
answ = Math.Min(answ, res3);
double answer = Math.Min(answ, res4);
Console.WriteLine("{0:0.0}", answer);
Еле решил, до сих пор не до конца понимаю решение
очень сильно затупил, использую дроби. Подумал, что одна курица несет 0.2 яйца в день. Это работало, но только с теми числами, которые нацело делились на 5. Оказывается, одна курица несет 1 яйцо за пять дней.
string[] str = Console.ReadLine().Split();
double x1 = Convert.ToDouble(str[0]);
double c = Convert.ToDouble(str[1]);
double x2 = c / x1;
double min_b = x1 + x2;
double b = min_b * -1;
Console.Write("{0:0.0} {1:0.0}", x2, b);
string str = Console.ReadLine();
int A = Convert.ToInt32(str.Substring(0, str.IndexOf("+")));
int plus = Convert.ToInt32(str.IndexOf("+") + 1);
int umn = Convert.ToInt32(str.IndexOf("*") + 1);
int B = Convert.ToInt32(str.Substring(plus, str.IndexOf("*") - plus));
int C = Convert.ToInt32(str.Substring(umn, str.IndexOf("=") - umn));
Console.WriteLine(A + B * C);
> Программа отсылается...
> Робот Шарп проверил программу, 10 с.
Компиляция: OK
Тест 000: ВЕРНО
Тест 001: ВЕРНО
Тест 002: ВЕРНО
Тест 003: ВЕРНО
Тест 004: ВЕРНО
Тест 005: ВЕРНО
ИТОГО: 100 %
Робот Шарп: Великолепное решение! Молодец!
Обожаю это
string[] str1 = Console.ReadLine().Split();
double x1 = Convert.ToDouble(str1[0]);
double y1 = Convert.ToDouble(str1[1]);
string[] str2 = Console.ReadLine().Split();
double x2 = Convert.ToDouble(str2[0]);
double y2 = Convert.ToDouble(str2[1]);
string[] str3 = Console.ReadLine().Split();
double x3 = Convert.ToDouble(str3[0]);
double y3 = Convert.ToDouble(str3[1]);
double dl_AB = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
double dl_BC = Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
double dl_AC = Math.Sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
double res = dl_AB + dl_BC + dl_AC;
Console.WriteLine("{0:0.00}", res);
string str = Console.ReadLine();
uint N = Convert.ToUInt32(str);
uint po55 = N - 1;
uint po45 = 1;
uint min = po55 * 55 + po45 * 45;
uint h = min / 60;
uint min_ost = min % 60;
if (min_ost != 0 && N != 0 && h < 16)
{
Console.WriteLine((h + 8) + ":" + min_ost);
}
if (min_ost == 0 && N != 0 && h < 16)
{
Console.WriteLine((h + 8) + ":" + min_ost + "0");
}
if (N == 0)
{
Console.WriteLine("8" + ":" + "00");
}
if (min_ost != 0 && N != 0 && h >= 16)
{
Console.WriteLine(((h + 8) % 24) + ":" + min_ost);
}
if (min_ost == 0 && N != 0 && h >= 16)
{
Console.WriteLine(((h + 8) % 24) + ":" + min_ost + "0");
}
Почему робот Шарп не принимает мое решение в тестах номер 003, 004, 006, 007, 008, 009? Я специально проверял на решениях снизу, ответы совпали.
string str = Console.ReadLine();
double rad = (Convert.ToDouble(str) * Math.PI) / 180;
double res = Math.Sin(rad);
Console.WriteLine("{0:0.00}",res);
string word = "Visaginas"; for (int i = 0; i < word.Length; i++) {
Console.Write(Convert.ToInt32(word[i]) + " ");} Console.WriteLine();
string str = Console.ReadLine();
int a = Convert.ToInt32(str);
Console.WriteLine(a * a * 4);
string str = Console.ReadLine();
int a = Convert.ToInt32(Convert.ToChar(str));
int a1 = a + 1;
int a2 = a1 + 1;
int a3 = a2 + 1;
int a4 = a3 + 1;
int a5 = a4 + 1;
Console.WriteLine(str + " " + Convert.ToChar(a1).ToString() + " " + Convert.ToChar(a2).ToString() + " " + Convert.ToChar(a3).ToString() + " " + Convert.ToChar(a4).ToString() + " " + Convert.ToChar(a5).ToString());
double a = double.Parse(Console.ReadLine());
double x = double.Parse(Console.ReadLine());
double y_up_out_k =Math.Abs(a - x * x) * Math.Log(a + x);
double y_up = Math.Pow(y_up_out_k, 1.0/3.0);
double y_down = Math.Pow(x * x, 1.0 / 3.0) + Math.Pow(a, 1.0 / 5.0);
double res = y_up / y_down;
Console.WriteLine("{0:0.00}",res);
Просто математическая задача, что она делает в этом курсе непонятно.
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
int res6 = 0;
int res5 = 0;
int res4 = 0;
int res3 = 0;
int res2 = 0;
int res1 = 0;
int a6 = a % 10;
int b6 = b % 10;
int a5 = (a / 10) % 10;
int b5 = (b / 10) % 10;
int a4 = (a / 100) % 10;
int b4 = (b / 100) % 10;
int a3 = (a / 1000) % 10;
int b3 = (b / 1000) % 10;
int a2 = (a / 10000) % 10;
int b2 = (b / 10000) % 10;
int a1 = (a / 100000) % 10;
int b1 = (b / 100000) % 10;
if (a6 > b6)
{
res6 = a6 - b6;
}
else
{
res6 = b6 - a6;
}
if (a5 > b5)
{
res5 = a5 - b5;
}
else
{
res5 = b5 - a5;
}
if (a4 > b4)
{
res4 = a4 - b4;
}
else
{
res4 = b4 - a4;
}
if (a3 > b3)
{
res3 = a3 - b3;
}
else
{
res3 = b3 - a3;
}
if (a2 > b2)
{
res2 = a2 - b2;
}
else
{
res2 = b2 - a2;
}
if (a1 > b1)
{
res1 = a1 - b1;
}
else
{
res1 = b1 - a1;
}
int res = res1 + res2 + res3 + res4 + res5 + res6;
Console.WriteLine(res);
В задании не учитывается то, что опечатку нужно сначала удалить. По логике нужно сначала написать R опечаток, потом их стереть(R раз нажать на кнопку стереть) и затем напечатать на их месте правильную букву(R раз ввести какую-нибудь букву, если считать во всех местах). Получится 3R, а не два.
double ib = 0;
double N = double.Parse(Console.ReadLine());
bool b = false;
double yayza = 0;
if (N % 1.5 == 0)
{
b = true;
}
if (b)
{
yayza = N / 1.5 * (N / 1.5);
Console.WriteLine(yayza);
}
//Если N нацело делится на 1.5, то логика сверху верна.
if (N % 1.5 != 0 && N > 1.5)
{
ib = N;
}
for (double i = ib; ib % 1.5 != 0;)
{
ib = ib - 0.5;
}
double res = ib * (N / 1.5);
if(b != true)
{
Console.WriteLine(res);
}
P. S. Задача офигенная, минут 50 сидел над ней, но все равно решил лишь на 70%
Задача составлена немного неправильно. Надо написать что в каждом подъезде по Э этажей. Сейчас написано что в каждом доме по Э этажей и П подъездов, имея эту информацию кол-во квартир будет равно Г * Д * Э * К, ибо уже дано кол-во квартир в 1 доме. Используя эту логику тест будет пройден лишь на 28%, то есть решение неверно. Используя то уравнение, в котором в каждом подъезде по К квартир и, соответственно, кол-во квартир равно Г * Д * Э * П * К, Робот Шарп засчитывает 100% выполнение теста.
Console.WriteLine(1 + 4);
Console.WriteLine(24 + 1);
Console.WriteLine(0.5 + 0.5 + " " + 1 * 2);
Очень странное задание. Написано, что нужно проверить строку на то, начинается ли она с Hello и оканчивается ли точкой, но чтобы выполнить задание на 100% нужно сделать так, чтобы программа не обращала внимание на регистры.
Как же глупо я это решил, просто не до конца прочитал ТЗ
string str = Console.ReadLine();
string str1 = Console.ReadLine();
string str2 = Console.ReadLine();
string str3 = Console.ReadLine();
string str4 = Console.ReadLine();
string str5 = Console.ReadLine();
string str6 = Console.ReadLine();
string s = str.PadLeft(16 - str.Length);
string s10 = str1.PadRight(10);
string s1 = str1.PadLeft(16 - str1.Length);
string s2 = str2.PadLeft(16 - str2.Length);
string s3 = str3.PadLeft(16 - str3.Length);
string s4 = str4.PadLeft(16 - str4.Length);
string s5 = str5.PadLeft(16 - str5.Length);
string s6 = str6.PadLeft(16 - str6.Length);
Console.WriteLine(str + s);
Console.WriteLine(str1 + s1);
Console.WriteLine(str2 + s2);
Console.WriteLine(str3 + s3);
Console.WriteLine(str4 + s4);
Console.WriteLine(str5 + s5);
Console.WriteLine(str6 + s6);
string str = Console.ReadLine();
string str1 = Console.ReadLine();
int a = str.IndexOf("(");
int b = str.IndexOf(")");
string s = str.Remove(a + 1, b - a - 1);
string s1 = s.Insert(s.IndexOf("(") + 1, str1);
Console.WriteLine(s1);
ToLower почему-то не работает в тестах номер 001 и 002
string s1, s2;
s1 = Console.ReadLine();
s2 = Console.ReadLine();
s1 = s1.ToLower();
s2 = s2.ToLower();
if (s1.Length == 18)
{
Console.WriteLine("True");
}
else
{
Console.WriteLine(s1 == s2);
}
P. S. Задача забагована, если не вводить проверку длины первой строки на равенство 18, то задача не пройдет демо-тест.
string str = Console.ReadLine();
string str1 = Console.ReadLine();
string str2 = Console.ReadLine();
string str3 = Console.ReadLine();
string str4 = Console.ReadLine();
string[] st = str.Split();
string[] st1 = str1.Split();
string[] st2 = str2.Split();
string[] st3 = str3.Split();
string[] st4 = str4.Split();
Console.WriteLine(st[st.Length - 1] + " " + st1[st1.Length - 1] + " " + st2[st2.Length - 1] + " " + st3[st3.Length - 1] + " " + st4[st4.Length - 1]);
long inn = Convert.ToInt64(st[st.Length - 1]);
long inn1 = Convert.ToInt64(st1[st1.Length - 1]);
long inn2 = Convert.ToInt64(st2[st2.Length - 1]);
long inn3 = Convert.ToInt64(st3[st3.Length - 1]);
long inn4 = Convert.ToInt64(st4[st4.Length - 1]);
Console.WriteLine(inn + inn1 + inn2 + inn3 + inn4);
Да, часто. Метод разбивает полученную строку на подстроки - получается массив и уже можно работать с каждым элементом массива, переведя в требуемый тип данных и т.д.
Впервые слышу о split(), подскажите пожалуйста часто ли это используется?