This file contains hidden or 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 | |
for($i=1;$i<=112;$i+=3){ | |
$sum+=$i; | |
echo $i." "; | |
} | |
echo "<br>$sum"; |
This file contains hidden or 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 | |
function parse_timestamp( $t = 0 ) | |
{ | |
//if you need to translate all the seconds in days or minutes | |
//you must delete this operation '%' | |
$day = ( $t / 86400 ) % 30; | |
$hour = ( $t / 3600 ) % 24; | |
$min = ( $t / 60 ) % 60; |
This file contains hidden or 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 | |
echo "<pre>"; | |
$y = date("Y"); | |
$date = new DateTime("01.01.{$y}"); | |
$flag = false; | |
$m = $date->format("m"); | |
while ($date->format("Y") == $y) | |
{ | |
if ($flag === false) |
This file contains hidden or 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 | |
$arr = [1,1,2,3,4,5,5,6]; | |
$result = array_unique($arr); | |
print_r($result); |
This file contains hidden or 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 | |
foreach (range(1,6) as $array){ | |
if($array%2!==0){ | |
echo "Не четное число: $array <br>"; | |
}else{ | |
echo "Четное число: $array <br>"; | |
} | |
} |
This file contains hidden or 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 | |
$day = 6; | |
foreach (range(1, 7) as $weekDays) { | |
if ($weekDays == $day) { | |
if ($day < 6) { | |
$workDay = $weekDays; | |
} | |
if ($day >= 6) { | |
array_splice($weekDays, 4); | |
$weekendDay = $weekDays; |
This file contains hidden or 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 | |
class Car{ | |
public $model; | |
public $speed; | |
public $doors; | |
public $year; | |
public function __construct($model,$speed,$doors,$year) | |
{ |
This file contains hidden or 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
def triangle_kind(a, b, c) | |
if a.equal?(b) && a.equal?(c) | |
p 'равносторонний' | |
elsif a.equal?(b) || a.equal?(c) || b.equal?(c) | |
p 'равнобедренный' | |
elsif right_trianle? a, b, c | |
p 'прямоугольный' | |
else | |
p 'чорт пойми шо' | |
end |
This file contains hidden or 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
def optimal(weight) | |
opti = weight - 110 | |
if(opti < 0) | |
return "Твой вес уже в порядке" | |
else | |
return opti | |
end | |
end | |
This file contains hidden or 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
def Discr(a,b,c) | |
d = (b*b)-4*(a*c) | |
return d | |
end | |
def Out(d,a,b,c) | |
if(d > 0) | |
x1 = (-b + Math.sqrt((b*b)-4*(a*c)))/(2*a) | |
x2 = (-b - Math.sqrt((b*b)-4*(a*c)))/(2*a) |
NewerOlder