From e3719e817ccd68a2d57468da5f518ea5c0c79b74 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Fri, 21 Apr 2023 21:32:41 +0000 Subject: [PATCH 01/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20do=20Exerc=C3=ADcio?= =?UTF-8?q?=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Triangulo.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Triangulo.js diff --git a/Triangulo.js b/Triangulo.js new file mode 100644 index 0000000..78ece02 --- /dev/null +++ b/Triangulo.js @@ -0,0 +1,13 @@ +var numLinhas = prompt("Digite o número de linhas: "); + +for(var comp = 1; comp <= numLinhas; comp++){ + + for(var comp2 = 0; comp2 <= comp; comp2++){ + + document.write("#"); + + } + + document.write("
"); + +} \ No newline at end of file From a45cf6e351358887bd3253ec59b24c10d44d3327 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Fri, 21 Apr 2023 21:35:41 +0000 Subject: [PATCH 02/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Triangulo.js | 4 ++-- Xadrez.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 Xadrez.js diff --git a/Triangulo.js b/Triangulo.js index 78ece02..10c6154 100644 --- a/Triangulo.js +++ b/Triangulo.js @@ -1,8 +1,8 @@ var numLinhas = prompt("Digite o número de linhas: "); -for(var comp = 1; comp <= numLinhas; comp++){ +for(let comp = 1; comp <= numLinhas; comp++){ - for(var comp2 = 0; comp2 <= comp; comp2++){ + for(let comp2 = 0; comp2 <= comp; comp2++){ document.write("#"); diff --git a/Xadrez.js b/Xadrez.js new file mode 100644 index 0000000..8ad3880 --- /dev/null +++ b/Xadrez.js @@ -0,0 +1,11 @@ +var numLinhas = prompt("Digite o número de linhas: "); + +for(var comp = 1; comp <= numLinhas; comp++){ + + document.write("#"); + + + + document.write("
"); + +} \ No newline at end of file From 83cc5bbb9f27ca60d050a090d34e34b3ab90c6fc Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Fri, 21 Apr 2023 21:41:28 +0000 Subject: [PATCH 03/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Xadrez.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Xadrez.js b/Xadrez.js index 8ad3880..732a63b 100644 --- a/Xadrez.js +++ b/Xadrez.js @@ -1,10 +1,14 @@ var numLinhas = prompt("Digite o número de linhas: "); -for(var comp = 1; comp <= numLinhas; comp++){ +for(let comp = 1; comp <= numLinhas; comp++){ - document.write("#"); + if(comp % 2 == 0){ - + document.write(" "); + + } + + document.write("# # # #"); document.write("
"); From dc1fbdffcd4e2a5959641309c033509fb6ff0d02 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Fri, 21 Apr 2023 22:17:35 +0000 Subject: [PATCH 04/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Palindromos.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Palindromos.js diff --git a/Palindromos.js b/Palindromos.js new file mode 100644 index 0000000..4cddca1 --- /dev/null +++ b/Palindromos.js @@ -0,0 +1,26 @@ +var palavraOriginal = prompt("Escreva uma palavra: "); +var tamanho = palavraOriginal.length - 1; +var verifica = 0; + +var palavra = palavraOriginal.toLocaleLowerCase(); + + +for (let comp = 0; comp < palavra.length; comp++){ + + if(palavra[comp] == palavra[tamanho - comp]){ + + verifica++; + + } + +} + +if(verifica == palavra.length){ + + document.writeln("A palavra ", palavraOriginal," é um palíndromo!"); + +} else { + + document.writeln("A palavra ", palavraOriginal," não é um palíndromo!"); + +} \ No newline at end of file From 966a6aa3edc6b3bf6ebdf32b68623835ce01b425 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Fri, 21 Apr 2023 22:23:34 +0000 Subject: [PATCH 05/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FizzBuzz.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 FizzBuzz.js diff --git a/FizzBuzz.js b/FizzBuzz.js new file mode 100644 index 0000000..c0bbf0d --- /dev/null +++ b/FizzBuzz.js @@ -0,0 +1,21 @@ +for(let comp = 1; comp <= 100; comp++){ + + if(comp % 3 == 0 && comp % 5 == 0){ + + console.log("FizzBuzz"); + + } else if(comp % 3 == 0){ + + console.log("Fizz"); + + } else if(comp % 5 == 0){ + + console.log("Buzz"); + + } else { + + console.log(comp); + + } + +} \ No newline at end of file From e20008fc1ef682b0b68366c12917fea1f83ac339 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 15:50:38 +0000 Subject: [PATCH 06/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MinMax.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 MinMax.js diff --git a/MinMax.js b/MinMax.js new file mode 100644 index 0000000..710b655 --- /dev/null +++ b/MinMax.js @@ -0,0 +1,55 @@ +function min(a, b){ + + if(a < b){ + + return a; + + } + else if(a > b){ + + return b; + + } + else { + + return "same"; + + } + +} + +function max(a, b){ + + if(a > b){ + + return a; + + } + else if(a < b){ + + return b; + + } + else { + + return "same"; + + } + +} + +var a = prompt("Digite um número: "); +var b = prompt("Digite outro número: "); +var maior = max(a, b); +var menor = min(a, b); + +if(maior == menor){ + + alert("Os dois números são iguais."); + +} +else { + + alert("O maior número é: "+ maior +"\nO menor número é: "+ menor); + +} \ No newline at end of file From 222a9f5edfee6d1f712a2c16d15dc3b9e6d5c2a3 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 16:16:39 +0000 Subject: [PATCH 07/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContarChars.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ContarChars.js diff --git a/ContarChars.js b/ContarChars.js new file mode 100644 index 0000000..c7ff39c --- /dev/null +++ b/ContarChars.js @@ -0,0 +1,38 @@ +function countChars(frase, c){ + + let qtdChar = 0; + + for(let comp = 0; comp < frase.length; comp++){ + + if(frase[comp] == c){ + + qtdChar++; + + } + + } + + return qtdChar; + +} + +var frase = prompt("Escreva uma frase qualquer: "); +var char = prompt("Digite um caractere: "); + +var charAparece = countChars(frase, char); + +if (charAparece == 0){ + + alert("O caractere '"+ char +"' não aparece nessa frase."); + +} +else if(charAparece == 1){ + + alert("O caractere '"+ char +"' aparece "+ charAparece +" vez na frase."); + +} +else { + + alert("O caractere '"+ char +"' aparece "+ charAparece +" vezes na frase."); + +} \ No newline at end of file From 98caf6164ac65863b5bd7364952eebc6b1acb261 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 17:22:22 +0000 Subject: [PATCH 08/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Intervalos.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Intervalos.js diff --git a/Intervalos.js b/Intervalos.js new file mode 100644 index 0000000..86dbc2c --- /dev/null +++ b/Intervalos.js @@ -0,0 +1,32 @@ +function range(min, max){ + + let numerosEntre = []; + + for(let comp = (min + 1); comp < max; comp++){ + + numerosEntre.push(comp); + + } + + return numerosEntre; + +} + +var numMin = prompt("Digite um número: "); +var numMax = prompt("Digite outro número: "); +var aux = numMin; + +if(aux > numMax){ + + aux = numMax; + numMax = numMin; + numMin = aux; + +} + +numMin = numMin++; +numMax = numMax++; + +numeros = range(numMin, numMax); + +console.log("Os números entre "+ numMin +" e "+ numMax +" são: "+ numeros +"."); \ No newline at end of file From 17fc9e80cd5f7f519fc683a011df5f138df9503d Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 19:47:23 +0000 Subject: [PATCH 09/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ModDois.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ModDois.js diff --git a/ModDois.js b/ModDois.js new file mode 100644 index 0000000..4834a55 --- /dev/null +++ b/ModDois.js @@ -0,0 +1,42 @@ +function mod2(number){ + + let num = number - 2; + let retorno; + + if(num >= 2){ + + retorno = mod2(num); + + } + else if (num < 2){ + + if(num == 0){ + + return true + + } + else { + + return false; + + } + + } + + return retorno; + +} + +var numUser = prompt("Digite um número: "); +var bool = mod2(numUser); + +if(bool == true){ + + alert("O número "+ numUser +" é divisível por 2!"); + +} +else { + + alert("O número "+ numUser +" não é divisível por 2!"); + +} \ No newline at end of file From ab4392880db8639775293ce57b7a90d6785f43c7 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 19:52:42 +0000 Subject: [PATCH 10/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ModNum.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ModNum.js diff --git a/ModNum.js b/ModNum.js new file mode 100644 index 0000000..c67e1cc --- /dev/null +++ b/ModNum.js @@ -0,0 +1,43 @@ +function modNum(number, mod){ + + let num = number - mod; + let retorno; + + if(num >= mod){ + + retorno = modNum(num, mod); + + } + else if (num < mod){ + + if(num == 0){ + + return true + + } + else { + + return false; + + } + + } + + return retorno; + +} + +var numUser = prompt("Digite um número: "); +var modUser = prompt("Digite um número para verificar a divisibilidade: "); +var bool = modNum(numUser, modUser); + +if(bool == true){ + + alert("O número "+ numUser +" é divisível por "+ modUser +"!"); + +} +else { + + alert("O número "+ numUser +" não é divisível por "+ modUser +"!"); + +} \ No newline at end of file From 1f663d9906a86ce5f168a23bec53cd34f88fe8c9 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 20:06:48 +0000 Subject: [PATCH 11/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IntervalosVariacao.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 IntervalosVariacao.js diff --git a/IntervalosVariacao.js b/IntervalosVariacao.js new file mode 100644 index 0000000..518359a --- /dev/null +++ b/IntervalosVariacao.js @@ -0,0 +1,35 @@ +function range(min, max, i){ + + let numerosEntre = []; + + for(let comp = (min + 1); comp < max; comp++){ + + numerosEntre.push(comp); + comp = comp + (i - 1); + + } + + return numerosEntre; + +} + +var numMin = prompt("Digite um número: "); +var numMax = prompt("Digite outro número: "); +var intervalo = prompt("Digite o intervalo entre eles: "); +var aux = numMin; + +if(aux > numMax){ + + aux = numMax; + numMax = numMin; + numMin = aux; + +} + +numMin = numMin++; +numMax = numMax++; +intervalo = intervalo++; + +numeros = range(numMin, numMax, intervalo); + +console.log("Os números entre "+ numMin +" e "+ numMax +" contando de "+ intervalo +" em "+ intervalo +" são: "+ numeros +"."); \ No newline at end of file From b6494bed3b25e90c08e2af5fa6da1ba6d9ff6b6a Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 20:12:11 +0000 Subject: [PATCH 12/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IntervalosVariacao.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IntervalosVariacao.js b/IntervalosVariacao.js index 518359a..c02a4ce 100644 --- a/IntervalosVariacao.js +++ b/IntervalosVariacao.js @@ -18,6 +18,10 @@ var numMax = prompt("Digite outro número: "); var intervalo = prompt("Digite o intervalo entre eles: "); var aux = numMin; +numMin = numMin++; +numMax = numMax++; +intervalo = intervalo++; + if(aux > numMax){ aux = numMax; @@ -26,10 +30,6 @@ if(aux > numMax){ } -numMin = numMin++; -numMax = numMax++; -intervalo = intervalo++; - numeros = range(numMin, numMax, intervalo); console.log("Os números entre "+ numMin +" e "+ numMax +" contando de "+ intervalo +" em "+ intervalo +" são: "+ numeros +"."); \ No newline at end of file From 49f7940d7e166b59eace6353f7318968f8a3a2a1 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 20:12:34 +0000 Subject: [PATCH 13/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Intervalos.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Intervalos.js b/Intervalos.js index 86dbc2c..52737ec 100644 --- a/Intervalos.js +++ b/Intervalos.js @@ -16,6 +16,9 @@ var numMin = prompt("Digite um número: "); var numMax = prompt("Digite outro número: "); var aux = numMin; +numMin = numMin++; +numMax = numMax++; + if(aux > numMax){ aux = numMax; @@ -24,8 +27,6 @@ if(aux > numMax){ } -numMin = numMin++; -numMax = numMax++; numeros = range(numMin, numMax); From d1a500a6ece80eac1480145fdba03d8622f55982 Mon Sep 17 00:00:00 2001 From: Bernardo-O-Silva <2021951558@teiacoltec.org> Date: Sat, 22 Apr 2023 20:30:43 +0000 Subject: [PATCH 14/14] =?UTF-8?q?Resolu=C3=A7=C3=A3o=20Exerc=C3=ADcio=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reverso.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Reverso.js diff --git a/Reverso.js b/Reverso.js new file mode 100644 index 0000000..b10db7e --- /dev/null +++ b/Reverso.js @@ -0,0 +1,30 @@ +function reverseArray(array){ + + let tamanho = (array.length - 1); + let yarra = []; + let pos = 0; + + for(let comp = tamanho; comp >= 0; comp--){ + + yarra[pos] = array[comp]; + + pos++; + + } + + return yarra; +} + +var numTotalArray = prompt("Digite o total de elementos no seu array: "); +var array = []; +var yarra = []; + +for(let comp = 0; comp < numTotalArray; comp++){ + + array.push(prompt("Digite o "+ (comp + 1) +"º elemento: ")); + +} + +yarra = reverseArray(array); + +alert("O array digitado ao contrário é: "+ yarra); \ No newline at end of file