-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (55 loc) · 1.91 KB
/
Copy pathProgram.cs
File metadata and controls
67 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//Напишите программу, которая принимает на вход пятизначное число и проверяет, является ли оно палиндромом.
/*
int reverse(int num, int acc)
{
while (num > 0)
{
acc = acc * 10 + num % 10; num /= 10;
}
return acc;
}
int num = int.Parse(Console.ReadLine()!);
Console.WriteLine((num == 0) || (reverse(num, 0) == num));
Console.ReadKey(true);
*/
//Напишите программу, которая принимает на вход координаты двух точек и находит расстояние между ними в 3D пространстве.
/*
int InputNum(string message)
{
Console.WriteLine(message);
int num = int.Parse(Console.ReadLine()!);
return num;
}
int xA = InputNum("Введите x для A;");
int yA = InputNum("Введите y для A;");
int zA = InputNum("Введите z для A;");
int xB = InputNum("Введите x для B;");
int yB = InputNum("Введите y для B;");
int zB = InputNum("Введите z для B;");
double Root(int xA, int yA, int zA, int xB, int yB, int zB)
{
double res1 = Math.Pow(xB - xA, 2);
double res2 = Math.Pow(yB - yA, 2);
double res3 = Math.Pow(zB - zA, 2);
double res = Math.Sqrt(res1 + res2 + res3);
return res;
}
double distance = Root(xA, yA, zA, xB, yB, zB);
Console.WriteLine(Math.Round(distance, 2));
*/
//Напишите программу, которая принимает на вход число (N) и выдаёт таблицу кубов чисел от 1 до N.
int InputNum(string message)
{
Console.WriteLine(message);
int num = int.Parse(Console.ReadLine()!);
return num;
}
int num = InputNum("Введите число N: ");
for(int i = 1; i <= num; i++)
{
Console.Write($"{Math.Pow(i, 3)}");
if (i < num)
Console.Write(", ");
else
Console.Write(".");
}