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
//Задание 1. Напишите программу: Дано расстояние в сантиметрах. Найти число полных метров в нем. | |
int cm = 12300; | |
double m = cm / 100; | |
Console.WriteLine($"В {cm} сантиметрах - {Math.Round(m, 0)} полных метров"); | |
//Задание 2. Напишите программу, в которую пользователь вводит с клавиатуры два числа. А программа сравнивает два введенных числа и выводит на консоль результат сравнения (два числа равны, первое число больше второго или первое число меньше второго). | |
Console.WriteLine($"Введите первое число: "); | |
int a = 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
Билет 1 | |
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
//Дана строка. Если она начинается на 'abc', то заменить их на 'www', иначе добавить в конец строки 'zzz'. | |
<?php | |
$arr = ['abcasdiuyabc', 'qabcyu']; | |
foreach($arr as $v){ | |
$reg = '/^(abc)(.*)/'; | |
if(preg_match($reg, $v)) | |
$v = preg_replace($reg, 'www\2', $v); | |
else | |
$v .= 'zzz'; | |
echo "<br/>$v"; |
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
//С помощью цикла for сформируйте строку '123456789' и запишите ее в переменную $str. | |
<?php | |
$str = ''; | |
for ($i = 1; $i <= 9; $i++) { | |
$str = $str . $i; | |
} | |
echo $str; // выведет '123456789' | |
?> |
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
<?php | |
/* | |
1. Написать скриптов в тетради | |
*/ | |
$txt = "Сизов Павел Николаевич"; | |
echo "Номер скрипта $txt!"."<br>"; | |
//Модуль числа | |
echo abs(-4)."<br>"; |
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
//Выведите с помощью цикла столбец четных чисел от 1 до 100. | |
<?php | |
$a = 1; | |
while ($a <= 100){ | |
echo $a.'<br>'; | |
$a++; | |
} | |
?> | |
//Заполните массив числами от 10 до 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
/*Напишите функцию PHP для округления числа с плавающей запятой от нуля до указанного числа десятичных знаков. | |
Примеры чисел: | |
(52.78001, 2) | |
(9.131001, 2) | |
(0.786001, 4) | |
(-.125481, 3) | |
-.125481 | |
*/ | |
<?php |
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
//Выведите строку "x больше y" если переменная $x > $y. | |
<?php | |
$x = 50; | |
$y = 10; | |
if ($x>$y) | |
{ | |
echo "x больше y"; | |
} | |
?> |
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
//Задания этого типа удобнее проверять здесь: https://www.onlinegdb.com/online_php_interpreter | |
//На вход подается строка из чисел, разделенных пробелами. Найдите максимальное произведение двух чисел из этой строки. | |
<?php | |
$line = trim(fgets(STDIN)); | |
$nums = explode(' ', $line); | |
$max = $nums[0] * $nums[1]; | |
foreach($nums as $i => $num1) { | |
foreach($nums as $j => $num2) { | |
if ($i === $j) { |
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
//Напишите скрипт PHP, чтобы получить самый большой ключ в массиве. | |
<?php | |
$ceu = array( "Italy"=>"Rome", "Luxembourg"=>"Luxembourg", "Belgium"=> "Brussels", | |
"Denmark"=>"Copenhagen", "Finland"=>"Helsinki", "France" => "Paris", "Slovakia"=>"Bratislava", | |
"Slovenia"=>"Ljubljana", "Germany" => "Berlin", "Greece" => "Athens", "Ireland"=>"Dublin", | |
"Netherlands"=>"Amsterdam", "Portugal"=>"Lisbon", "Spain"=>"Madrid", "Sweden"=>"Stockholm", | |
"United Kingdom"=>"London", "Cyprus"=>"Nicosia", "Lithuania"=>"Vilnius", "Czech Republic"=>"Prague", "Estonia"=>"Tallin", "Hungary"=>"Budapest", "Latvia"=>"Riga", "Malta"=> "Valetta","Austria" => "Vienna", "Poland"=>"Warsaw") ; | |
$max_key = max( array_keys( $ceu) ); | |
echo $max_key."\n"; | |
?> |
OlderNewer