forked from neves/curso-programacao
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,472 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<? | ||
$um = 1; | ||
$dois = 2; | ||
// if simples | ||
if ($dois > $um) | ||
echo "O maior eh o $dois \n"; | ||
|
||
// if com mais de um comando precisa de escopo.(dois pontos + endif) | ||
if ($dois > $um): | ||
echo "O maior eh o $dois \n"; | ||
echo "e o menor eh o $um \n"; | ||
endif; | ||
|
||
// if e else | ||
if ($um > $dois) | ||
echo "O maior eh o $um \n"; | ||
else | ||
echo "O maior eh o $dois \n"; | ||
|
||
// if e else com escopo | ||
if ($um > $dois): | ||
echo "O maior eh o $um \n"; | ||
echo "e o menor eh o $dois \n"; | ||
else: | ||
echo "O maior eh o $dois \n"; | ||
echo "e o menor eh o $um \n"; | ||
endif; | ||
|
||
// if dentro de else | ||
if ($um > $dois) | ||
echo "O maior eh o $um \n"; | ||
else | ||
if ($um == $dois) | ||
echo "Os numeros sao iguais! \n"; | ||
|
||
// elseif | ||
if ($um > $dois) | ||
echo "O maior eh o $um \n"; | ||
elseif ($um == $dois) | ||
echo "Os numeros sao iguais! \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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$n1 = $argv[1]; | ||
$n2 = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$soma = $n1 + $n2; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$n1 + $n2 = $soma | ||
" | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$nome = "John Doe"; | ||
$email = "[email protected]"; | ||
$idade = 64; | ||
$estado = "PR"; | ||
$cidade = "Maringa"; | ||
$sexo = "Masculino"; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
____________________Dados Cadastrais____________________ | ||
Nome : $nome | ||
Email: $email | ||
Idade: $idade anos | ||
Local: $cidade/$estado | ||
Sexo : $sexo | ||
======================================================== | ||
"; | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$n = $argv[1]; | ||
|
||
// LOGICA | ||
|
||
$n1 = $n * 1; | ||
$n2 = $n * 2; | ||
$n3 = $n * 3; | ||
$n4 = $n * 4; | ||
$n5 = $n * 5; | ||
$n6 = $n * 6; | ||
$n7 = $n * 7; | ||
$n8 = $n * 8; | ||
$n9 = $n * 9; | ||
$n10 = $n * 10; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
------------- | ||
TABUADA DO $n | ||
============= | ||
$n x 1 = $n1 | ||
$n x 2 = $n2 | ||
$n x 3 = $n3 | ||
$n x 4 = $n4 | ||
$n x 5 = $n5 | ||
$n x 6 = $n6 | ||
$n x 7 = $n7 | ||
$n x 8 = $n8 | ||
$n x 9 = $n9 | ||
$n x 10 = $n10 | ||
_____________ | ||
" | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$b1 = $argv[1]; | ||
$b2 = $argv[2]; | ||
$b3 = $argv[3]; | ||
$b4 = $argv[4]; | ||
|
||
// LOGICA | ||
|
||
$media = ($b1 + $b2 + $b3 + $b4) / 4; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
Notas dos Bimestres | ||
=================== | ||
1 Bimestre: $b1 | ||
2 Bimestre: $b2 | ||
3 Bimestre: $b3 | ||
4 Bimestre: $b4 | ||
------------------- | ||
Media Anual: $media | ||
"; | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$n1 = $argv[1]; | ||
$n2 = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$soma = $n1 + $n2; | ||
$sub = $n1 - $n2; | ||
$mult = $n1 * $n2; | ||
$div = $n1 / $n2; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$n1 + $n2 = $soma | ||
$n1 - $n2 = $sub | ||
$n1 x $n2 = $mult | ||
$n1 / $n2 = $div | ||
"; | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$char = $argv[1]; | ||
|
||
// LOGICA | ||
|
||
$codigo = ord($char); | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$char = $codigo | ||
" | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$codigo = $argv[1]; | ||
|
||
// LOGICA | ||
|
||
$char = chr($codigo); | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$codigo = [$char] | ||
" | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$min = $argv[1]; | ||
$max = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$sorteio = mt_rand($min, $max); | ||
|
||
// SAIDA | ||
|
||
echo " | ||
sorteado o numero $sorteio entre $min e $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$resultados = $argv[1]; | ||
$porPagina = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$paginas = ceil($resultados / $porPagina); | ||
|
||
// .............................. SAÍDA .............................. | ||
|
||
echo " | ||
$resultados resultados exibidos em $paginas paginas | ||
"; | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$n1 = $argv[1]; | ||
$n2 = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$divisao = floor($n1 / $n2); | ||
$resto = $n1 % $n2; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$n1 dividido por $n2 = $divisao com resto $resto | ||
$n2 x $divisao + $resto = $n1 | ||
" | ||
|
||
?> |
21 changes: 21 additions & 0 deletions
21
algoritmos/php/01-variaveis/14-resto_da_divisao_manual.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$n1 = $argv[1]; | ||
$n2 = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
$divisao = floor($n1 / $n2); | ||
$resto = $n1 - $divisao * $n2; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$n1 dividido por $n2 = $divisao com resto $resto | ||
$n2 x $divisao + $resto = $n1 | ||
" | ||
|
||
?> |
21 changes: 21 additions & 0 deletions
21
algoritmos/php/01-variaveis/15-area_e_perimetro_do_quadrado.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$lado = $argv[1]; | ||
|
||
// LOGICA | ||
|
||
$area = $lado * $lado; | ||
$perimetro = 4 * $lado; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
O quadrado de lado {$lado}cm, | ||
possui area de {$area}cm2 quadrados e | ||
perimetro de {$perimetro}cm. | ||
"; | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$a = $argv[1]; | ||
$b = $argv[2]; | ||
|
||
// LOGICA | ||
|
||
// utilizar uma variável temporária para fazer a troca | ||
$temp = $a; | ||
$a = $b; | ||
$b = $temp; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$a $b | ||
" | ||
|
||
?> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<? | ||
|
||
// ENTRADA | ||
|
||
$a = $argv[1]; | ||
$b = $argv[2]; | ||
$c = $argv[3]; | ||
$d = $argv[4]; | ||
|
||
// Trocar a e d | ||
$temp = $a; | ||
$a = $d; | ||
$d = $temp; | ||
|
||
// Trocar b e c | ||
$temp = $c; | ||
$c = $b; | ||
$b = $temp; | ||
|
||
// SAIDA | ||
|
||
echo " | ||
$a $b $c $d | ||
" | ||
|
||
?> |
Oops, something went wrong.