This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 10: Напишите программу, которая принимает на вход трёхзначное число и на выходе показывает вторую цифру этого числа. | |
// 456 -> 5 | |
// 782 -> 8 | |
// 918 -> 1 | |
Console.Clear(); | |
Console.WriteLine("Задача 10 "); | |
Console.Write("Введи трёхзначное число: "); | |
int threeDigitNumber = Convert.ToInt32(Console.ReadLine()); | |
string stringNumber = Convert.ToString(threeDigitNumber); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 19: Напишите программу, которая принимает на вход пятизначное число и проверяет, является ли оно палиндромом. | |
// 14212 -> нет | |
// 23432 -> да | |
// 12821 -> да | |
Console.WriteLine("Задача 19"); | |
Console.Write("Введите число: "); | |
string? number = Console.ReadLine(); | |
void CheckingNumber(string number){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 25: Напишите цикл, который принимает на вход два числа (A и B) и возводит число A в натуральную степень B. | |
// 3, 5 -> 243 (3⁵) | |
// 2, 4 -> 16 | |
Console.WriteLine($"\nЗадача 25. Возведене числа A в натуральную степень B"); | |
int Exponentiation(int numberA, int numberB){ | |
int result = 1; | |
for(int i=1; i <= numberB; i++){ | |
result = result * numberA; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 34: Задайте массив заполненный случайными положительными трёхзначными числами. Напишите программу, которая покажет количество чётных чисел в массиве. | |
// [345, 897, 568, 234] -> 2 | |
Console.Clear(); | |
Console.WriteLine($"Задача 34. Количество чётных чисел в массиве:\n"); | |
int[] numbers = new int[10]; | |
void FillArray(int[] array, int min, int max){ | |
for (int i = 0; i<array.Length; i++ ){ | |
array[i] = new Random().Next(min, max); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 41. Пользователь вводит с клавиатуры M чисел. Посчитайте, сколько чисел больше 0 ввёл пользователь. | |
// 0, 7, 8, -2, -2 -> 2 | |
// -1, -7, 567, 89, 223-> 3 | |
Console.Clear(); | |
Console.WriteLine($"Задача 41. Cколько чисел больше 0 ввёл пользователь \n"); | |
Console.Write($"Введи число М(количество чисел): "); | |
int m = Convert.ToInt32(Console.ReadLine()); | |
int[] massiveNumbers = new int[m]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 47: Задайте двумерный массив размером m×n, заполненный случайными вещественными числами. | |
// m = 3, n = 4. | |
// 0,5 7 -2 -0,2 | |
// 1 -3,3 8 -9,9 | |
// 8 7,8 -7,1 9 | |
Console.WriteLine($"Задача 47: Задайте двумерный массив размером m x n, заполненный случайными вещественными числами."); | |
Console.Write("Введите m: "); | |
int m = Convert.ToInt32(Console.ReadLine()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Задача 54: Задайте двумерный массив. Напишите программу, которая упорядочит по убыванию элементы каждой строки двумерного массива. | |
Console.Clear(); | |
Console.WriteLine($"Задача 54: Задайте двумерный массив. Напишите программу, которая упорядочит по убыванию элементы каждой строки двумерного массива."); | |
Console.WriteLine($"\nВведите размер массива m x n и диапазон случайных значений:"); | |
int m = InputNumbers("Введите m: "); | |
int n = InputNumbers("Введите n: "); | |
int range = InputNumbers("Введите диапазон: от 1 до "); | |
int[,] array = new int[m, n]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 64: Задайте значение N. Напишите программу, которая выведет все натуральные числа в промежутке от N до 1. | |
// N = 5 -> "5, 4, 3, 2, 1" | |
// N = 8 -> "8, 7, 6, 5, 4, 3, 2, 1" | |
Console.Clear(); | |
Console.WriteLine($"Задача 64: Задайте значение N. Напишите программу, которая выведет все натуральные числа в промежутке от N до 1."); | |
int n = InputNumbers("Введите n: "); | |
int count = 2; | |
PrintNumber(n, count); | |
Console.Write(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Задача 73: Есть число N. Сколько групп M, можно получить при разбиении всех чисел на группы, так чтобы в одной группе все числа были взаимно просты (все числа в группе друг на друга не делятся)? Найдите M при заданном N и получите одно из разбиений на группы N ≤ 10²⁰. Можно использовать рекурсию. | |
int n = InputNumbers("Введите число N: "); | |
int[] tempArray = CreateArray(n); | |
CreateRows(tempArray); | |
void CreateRows(int[] arrayCheck) | |
{ | |
int[] arrayTemp = new int[arrayCheck.Length]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Напишите программу, которая принимает на вход цифру, обозначающую день недели, и проверяет, является ли этот день выходным. | |
Пример: - 6 -> да - 7 -> да - 1 -> нет """ | |
def InputNumbers(inputText): | |
is_OK = False | |
while not is_OK: | |
try: | |
number = int(input(f"{inputText}")) | |
is_OK = True |
OlderNewer