Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gmakc-094423/7007ef8ec19c1d18d319d536aa4c4b8b to your computer and use it in GitHub Desktop.
Save gmakc-094423/7007ef8ec19c1d18d319d536aa4c4b8b to your computer and use it in GitHub Desktop.
Домашнее задание к семинару № 3
// Задача 19: Напишите программу, которая принимает на вход пятизначное число и проверяет, является ли оно палиндромом.
// 14212 -> нет
// 23432 -> да
// 12821 -> да
Console.WriteLine("Задача 19");
Console.Write("Введите число: ");
string? number = Console.ReadLine();
void CheckingNumber(string number){
if (number[0]==number[4] || number[1]==number[3]){
Console.WriteLine($"Ваше число: {number} - палиндром.");
}
else Console.WriteLine($"Ваше число: {number} - НЕ палиндром.");
}
if (number!.Length == 5){
CheckingNumber(number);
}
else Console.WriteLine($"Введи правильное число");
// Задача 21: Напишите программу, которая принимает на вход координаты двух точек и находит расстояние между ними в 3D пространстве.
// A (3,6,8); B (2,1,-7), -> 15.84
// A (7,-5, 0); B (1,-1,9) -> 11.53
Console.WriteLine("\n Задача 21");
int x1 = Coordinate("x", "A");
int y1 = Coordinate("y", "A");
int z1 = Coordinate("z", "A");
int x2 = Coordinate("x", "B");
int y2 = Coordinate("y", "B");
int z2 = Coordinate("z", "B");
int Coordinate(string coorName, string pointName)
{
Console.Write($"Введите координату {coorName} точки {pointName}: ");
return Convert.ToInt16(Console.ReadLine());
}
double Decision(double x1, double x2,
double y1, double y2,
double z1, double z2){
return Math.Sqrt(Math.Pow((x2-x1), 2) +
Math.Pow((y2-y1), 2) +
Math.Pow((z2-z1), 2));
}
double segmentLength = Math.Round (Decision(x1, x2, y1, y2, z1, z2), 2 );
Console.WriteLine($"Длина отрезка {segmentLength}");
//Задача 23: Напишите программу, которая принимает на вход число (N) и выдаёт таблицу кубов чисел от 1 до N.
// 3 -> 1, 8, 27
// 5 -> 1, 8, 27, 64, 125
Console.WriteLine("\n Задача 23");
Console.Write("Введите число: ");
int cube = Convert.ToInt32(Console.ReadLine());
void Cube(int[] cube){
int counter = 0;
int length = cube.Length;
while (counter < length){
cube[counter] = Convert.ToInt32(Math.Pow(counter, 3));
counter++;
}
}
void PrintArry(int[] coll){
int count = coll.Length;
int index = 0;
while(index < count){
Console.Write(coll[index]+ " ");
index++;
}
}
int[] arry = new int[cube+1];
Cube(arry);
PrintArry(arry);
@RomkaDV
Copy link

RomkaDV commented Feb 19, 2023

Храни Господь таких дюдей!!!)

@Natell2005
Copy link

плюсую!!!
От души благодарю!)

@pavelkulak
Copy link

pavelkulak commented Jul 16, 2023

76787, пишет что палиндром(????) Вместо || надо &&

@UktamL
Copy link

UktamL commented Sep 17, 2023

thank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment