From f5f5f9689ca7efdfe731ad32190645cc740b1eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Fri, 28 Apr 2023 22:53:16 -0300 Subject: [PATCH 01/27] Add files via upload --- Exercicio 4 - Numeros de 1 a 100.js | 15 ++++++++++++++ ...303\255cio 1 - Conceitos B\303\241sico.js" | 15 ++++++++++++++ "Exerc\303\255cio 2 - Xadrez.js" | 16 +++++++++++++++ "Exerc\303\255cio 3 - Palindromo.js" | 20 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 Exercicio 4 - Numeros de 1 a 100.js create mode 100644 "Exerc\303\255cio 1 - Conceitos B\303\241sico.js" create mode 100644 "Exerc\303\255cio 2 - Xadrez.js" create mode 100644 "Exerc\303\255cio 3 - Palindromo.js" diff --git a/Exercicio 4 - Numeros de 1 a 100.js b/Exercicio 4 - Numeros de 1 a 100.js new file mode 100644 index 0000000..f35f1f4 --- /dev/null +++ b/Exercicio 4 - Numeros de 1 a 100.js @@ -0,0 +1,15 @@ +for(i = 0; 100 > i; i++) +{ + console.log(i); + + if((i) % 3 == 0 && (i) % 5 == 0) + { console.log("- FizzBuzz"); } + + else if((i) % 3 == 0) + { console.log("- Fizz"); } + + else if((i) % 5 == 0) + { console.log("- Buzz"); } + + console.log("\n"); +} \ No newline at end of file diff --git "a/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" "b/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" new file mode 100644 index 0000000..0a753c0 --- /dev/null +++ "b/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" @@ -0,0 +1,15 @@ +var qntdelinhas = prompt("Digite um tamanho p/ o triangulo ser criado:"); + +var numporlinha=2; + +//para a quantidade de linhas que o usuário quer +for(i = 0; qntdelinhas > i; i++) +{ + //para cada linha + for(j = 0; j < numporlinha; j++) + { + console.log("#"); + } + console.log("\n"); + numporlinha++; +} diff --git "a/Exerc\303\255cio 2 - Xadrez.js" "b/Exerc\303\255cio 2 - Xadrez.js" new file mode 100644 index 0000000..570dae7 --- /dev/null +++ "b/Exerc\303\255cio 2 - Xadrez.js" @@ -0,0 +1,16 @@ +for(j = 0; j < 8; j++) +{ + for(i = 0; i < 8; i++) + { + //para cada linha + if((i + j) % 2 == 0) + { + console.log("#"); + } + else + { + console.log(" "); + } + } + console.log("\n"); +} \ No newline at end of file diff --git "a/Exerc\303\255cio 3 - Palindromo.js" "b/Exerc\303\255cio 3 - Palindromo.js" new file mode 100644 index 0000000..d848e0a --- /dev/null +++ "b/Exerc\303\255cio 3 - Palindromo.js" @@ -0,0 +1,20 @@ +var palindromo = prompt("Digite um palíndromo:"); + +var tampalindromo = palindromo.length; + +var resultado = true; +//para a quantidade de linhas que o usuário quer +for(i = 0; tampalindromo > i; i++) +{ + //para cada letra + if(palindromo[i] != palindromo[tampalindromo-1]) + { + resultado = false; + break; + } + else + { tampalindromo--;} +} +if(resultado == true){ console.log("É um palíndromo. "); } + +else { console.log("Não é um palíndromo. "); } From e372cfa6f0a43a6aa263ad2fee1c9ee37035fd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Fri, 28 Apr 2023 23:06:16 -0300 Subject: [PATCH 02/27] Add files via upload --- ...5cio 6 - M\303\241ximo e M\303\255nimo.js" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" diff --git "a/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" "b/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" new file mode 100644 index 0000000..f76fccb --- /dev/null +++ "b/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" @@ -0,0 +1,21 @@ + +var num1 = prompt("Número 1:"); +var num2 = prompt("Número 2:"); + +//calcula minimo +function calculaMinimo(num1, num2) +{ + if(num1 > num2) { return num2; } + else { return num1; } +} + +//calcula maximo +function calculaMaximo(num1, num2) +{ + if(num1 > num2) { return num1; } + else { return num2; } +} + +//resultado e chamada da funcao +console.log("Menor número: "+ calculaMinimo(num1, num2)); +console.log("Maior número: "+ calculaMaximo(num1, num2)); \ No newline at end of file From 4b46fee51077fbf88a791a82015e35d4d6be24a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Fri, 28 Apr 2023 23:22:20 -0300 Subject: [PATCH 03/27] Add files via upload --- "Exerc\303\255cio 7 - Modulo.js" | 16 ++++++++++++++++ ...\303\255cio 8 - Modulo e Recursividade.js" | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 "Exerc\303\255cio 7 - Modulo.js" create mode 100644 "Exerc\303\255cio 8 - Modulo e Recursividade.js" diff --git "a/Exerc\303\255cio 7 - Modulo.js" "b/Exerc\303\255cio 7 - Modulo.js" new file mode 100644 index 0000000..fc92804 --- /dev/null +++ "b/Exerc\303\255cio 7 - Modulo.js" @@ -0,0 +1,16 @@ +var num1 = prompt("Número:"); + +function mod2(number) +{ + if((number) % 2 == 0) + { return true; } + else { return false; } +} + +//resultado e chamada da funcao + +if((mod2(num1))==false) +{ console.log("o numero nao é divisivel por 2"); } + +else if((mod2(num1))== true) +{ console.log("o numero nao é divisivel por 2"); } \ No newline at end of file diff --git "a/Exerc\303\255cio 8 - Modulo e Recursividade.js" "b/Exerc\303\255cio 8 - Modulo e Recursividade.js" new file mode 100644 index 0000000..1a087fd --- /dev/null +++ "b/Exerc\303\255cio 8 - Modulo e Recursividade.js" @@ -0,0 +1,19 @@ +var num1 = prompt("Número:"); +var mod1 = prompt("Modulo:"); + +function mod(number, modinicio) +{ + if(number >= modinicio){ return mod(number - modinicio, modinicio); } + + if(number == 0) { return true; } + + else { return false; } +} + +//resultado e chamada da funcao + +if(mod(num1, mod1)== false) +{ console.log(" Não é Divisivel por " + mod1); } + +else if(mod(num1, mod1)== true) +{ console.log(" É Divisivel por " + mod1); } From 88adc93713718ee97de06debd18ba32680596443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Fri, 28 Apr 2023 23:32:07 -0300 Subject: [PATCH 04/27] Add files via upload --- "Exerc\303\255cio 9 -Caracteres.js" | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "Exerc\303\255cio 9 -Caracteres.js" diff --git "a/Exerc\303\255cio 9 -Caracteres.js" "b/Exerc\303\255cio 9 -Caracteres.js" new file mode 100644 index 0000000..8135443 --- /dev/null +++ "b/Exerc\303\255cio 9 -Caracteres.js" @@ -0,0 +1,20 @@ +var char = prompt("Cactere:"); +var string = prompt("String:"); + +function ContaCactere(string, char) +{ + var aparece = 0; + var tamanhostring = string.length-1 + + for(i = 0; tamanhostring > i; i++) + { + if(char == string[i]) + { + aparece++; + } + } + return aparece; +} + +//resultado e chamada da funcao +console.log(" O caractere " + char + " aparece " + ContaCactere(string,char) + " vezes"); From 0412888477433bb92c89bb7840a35cf52467ad9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 12:25:20 -0300 Subject: [PATCH 05/27] =?UTF-8?q?Rename=20Exercicio=204=20-=20Numeros=20de?= =?UTF-8?q?=201=20a=20100.js=20to=20Exerc=C3=ADcio=204=20-=20Numeros=20de?= =?UTF-8?q?=201=20a=20100.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e 1 a 100.js => "Exerc\303\255cio 4 - Numeros de 1 a 100.js" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Exercicio 4 - Numeros de 1 a 100.js => "Exerc\303\255cio 4 - Numeros de 1 a 100.js" (99%) diff --git a/Exercicio 4 - Numeros de 1 a 100.js "b/Exerc\303\255cio 4 - Numeros de 1 a 100.js" similarity index 99% rename from Exercicio 4 - Numeros de 1 a 100.js rename to "Exerc\303\255cio 4 - Numeros de 1 a 100.js" index f35f1f4..e9263cd 100644 --- a/Exercicio 4 - Numeros de 1 a 100.js +++ "b/Exerc\303\255cio 4 - Numeros de 1 a 100.js" @@ -12,4 +12,4 @@ for(i = 0; 100 > i; i++) { console.log("- Buzz"); } console.log("\n"); -} \ No newline at end of file +} From c3eb3ef561295c91bbe8c30192329bdba1116630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 12:27:18 -0300 Subject: [PATCH 06/27] =?UTF-8?q?Update=20Exerc=C3=ADcio=209=20-Caracteres?= =?UTF-8?q?.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 9 -Caracteres.js" | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git "a/Exerc\303\255cio 9 -Caracteres.js" "b/Exerc\303\255cio 9 -Caracteres.js" index 8135443..596dabf 100644 --- "a/Exerc\303\255cio 9 -Caracteres.js" +++ "b/Exerc\303\255cio 9 -Caracteres.js" @@ -1,14 +1,14 @@ var char = prompt("Cactere:"); var string = prompt("String:"); -function ContaCactere(string, char) +function countChars(frase, char) { var aparece = 0; - var tamanhostring = string.length-1 + var tamanhostring = frase.length-1 for(i = 0; tamanhostring > i; i++) { - if(char == string[i]) + if(char == frase[i]) { aparece++; } @@ -17,4 +17,4 @@ function ContaCactere(string, char) } //resultado e chamada da funcao -console.log(" O caractere " + char + " aparece " + ContaCactere(string,char) + " vezes"); +console.log(" O caractere " + char + " aparece " + countChars(string,char) + " vezes"); From 7e873fcd4129ddefb2c5ad57a6e87788923ad566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 14:36:51 -0300 Subject: [PATCH 07/27] Add files via upload --- "Exerc\303\255cio 10 - Range.js" | 15 +++++++++++++++ "Exerc\303\255cio 11- Range + variacao.js" | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 "Exerc\303\255cio 10 - Range.js" create mode 100644 "Exerc\303\255cio 11- Range + variacao.js" diff --git "a/Exerc\303\255cio 10 - Range.js" "b/Exerc\303\255cio 10 - Range.js" new file mode 100644 index 0000000..04698f1 --- /dev/null +++ "b/Exerc\303\255cio 10 - Range.js" @@ -0,0 +1,15 @@ +var min = prompt("Digite o mínimo:"); +var max = prompt("Digite o maximo:"); + +function range(min, max) +{ + var intervalo = [max-min]; + var j = 0; + for(i = min; max >= i; i++) + { + intervalo[j]= i; + j++ + } + return intervalo; +} +console.log(range(min,max)); \ No newline at end of file diff --git "a/Exerc\303\255cio 11- Range + variacao.js" "b/Exerc\303\255cio 11- Range + variacao.js" new file mode 100644 index 0000000..2d49892 --- /dev/null +++ "b/Exerc\303\255cio 11- Range + variacao.js" @@ -0,0 +1,18 @@ +var min = prompt("Digite o mínimo:"); +var max = prompt("Digite o maximo:"); +var variacao = prompt("Digite a variação:"); + +function range(min, max, variacao) +{ + var intervalo = []; + var j = 0; + + for(i = min; max >= i; i = i + variacao) + { + intervalo[j]= i; + j++; + } + return intervalo; +} + +console.log(range(min,max,variacao)); From 078cd189f58295118ea7b16ebc48951a8c660dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:12:56 -0300 Subject: [PATCH 08/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=201=20-=20Conceit?= =?UTF-8?q?os=20B=C3=A1sico.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 1 - Conceitos B\303\241sico.js" | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 "Exerc\303\255cio 1 - Conceitos B\303\241sico.js" diff --git "a/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" "b/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" deleted file mode 100644 index 0a753c0..0000000 --- "a/Exerc\303\255cio 1 - Conceitos B\303\241sico.js" +++ /dev/null @@ -1,15 +0,0 @@ -var qntdelinhas = prompt("Digite um tamanho p/ o triangulo ser criado:"); - -var numporlinha=2; - -//para a quantidade de linhas que o usuário quer -for(i = 0; qntdelinhas > i; i++) -{ - //para cada linha - for(j = 0; j < numporlinha; j++) - { - console.log("#"); - } - console.log("\n"); - numporlinha++; -} From 2c4048c6eb68e7ae7946774c93c3a1af017ccf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:13:18 -0300 Subject: [PATCH 09/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=2010=20-=20Range.?= =?UTF-8?q?js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 10 - Range.js" | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 "Exerc\303\255cio 10 - Range.js" diff --git "a/Exerc\303\255cio 10 - Range.js" "b/Exerc\303\255cio 10 - Range.js" deleted file mode 100644 index 04698f1..0000000 --- "a/Exerc\303\255cio 10 - Range.js" +++ /dev/null @@ -1,15 +0,0 @@ -var min = prompt("Digite o mínimo:"); -var max = prompt("Digite o maximo:"); - -function range(min, max) -{ - var intervalo = [max-min]; - var j = 0; - for(i = min; max >= i; i++) - { - intervalo[j]= i; - j++ - } - return intervalo; -} -console.log(range(min,max)); \ No newline at end of file From bb6bb47a14d4e3ea6dce10bbdea29aaa0427de27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:13:29 -0300 Subject: [PATCH 10/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=2011-=20Range=20+?= =?UTF-8?q?=20variacao.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 11- Range + variacao.js" | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 "Exerc\303\255cio 11- Range + variacao.js" diff --git "a/Exerc\303\255cio 11- Range + variacao.js" "b/Exerc\303\255cio 11- Range + variacao.js" deleted file mode 100644 index 2d49892..0000000 --- "a/Exerc\303\255cio 11- Range + variacao.js" +++ /dev/null @@ -1,18 +0,0 @@ -var min = prompt("Digite o mínimo:"); -var max = prompt("Digite o maximo:"); -var variacao = prompt("Digite a variação:"); - -function range(min, max, variacao) -{ - var intervalo = []; - var j = 0; - - for(i = min; max >= i; i = i + variacao) - { - intervalo[j]= i; - j++; - } - return intervalo; -} - -console.log(range(min,max,variacao)); From f930c436c45fc146887537b1c8b1017054ea08ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:13:40 -0300 Subject: [PATCH 11/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=202=20-=20Xadrez.?= =?UTF-8?q?js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 2 - Xadrez.js" | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 "Exerc\303\255cio 2 - Xadrez.js" diff --git "a/Exerc\303\255cio 2 - Xadrez.js" "b/Exerc\303\255cio 2 - Xadrez.js" deleted file mode 100644 index 570dae7..0000000 --- "a/Exerc\303\255cio 2 - Xadrez.js" +++ /dev/null @@ -1,16 +0,0 @@ -for(j = 0; j < 8; j++) -{ - for(i = 0; i < 8; i++) - { - //para cada linha - if((i + j) % 2 == 0) - { - console.log("#"); - } - else - { - console.log(" "); - } - } - console.log("\n"); -} \ No newline at end of file From e45d53f4b3d1457741af449cab9d2fb98f725b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:13:53 -0300 Subject: [PATCH 12/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=203=20-=20Palindr?= =?UTF-8?q?omo.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 3 - Palindromo.js" | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 "Exerc\303\255cio 3 - Palindromo.js" diff --git "a/Exerc\303\255cio 3 - Palindromo.js" "b/Exerc\303\255cio 3 - Palindromo.js" deleted file mode 100644 index d848e0a..0000000 --- "a/Exerc\303\255cio 3 - Palindromo.js" +++ /dev/null @@ -1,20 +0,0 @@ -var palindromo = prompt("Digite um palíndromo:"); - -var tampalindromo = palindromo.length; - -var resultado = true; -//para a quantidade de linhas que o usuário quer -for(i = 0; tampalindromo > i; i++) -{ - //para cada letra - if(palindromo[i] != palindromo[tampalindromo-1]) - { - resultado = false; - break; - } - else - { tampalindromo--;} -} -if(resultado == true){ console.log("É um palíndromo. "); } - -else { console.log("Não é um palíndromo. "); } From 73078f4fa22bd5e95b87b61ad7a9528c471a5311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:14:06 -0300 Subject: [PATCH 13/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=204=20-=20Numeros?= =?UTF-8?q?=20de=201=20a=20100.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 4 - Numeros de 1 a 100.js" | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 "Exerc\303\255cio 4 - Numeros de 1 a 100.js" diff --git "a/Exerc\303\255cio 4 - Numeros de 1 a 100.js" "b/Exerc\303\255cio 4 - Numeros de 1 a 100.js" deleted file mode 100644 index e9263cd..0000000 --- "a/Exerc\303\255cio 4 - Numeros de 1 a 100.js" +++ /dev/null @@ -1,15 +0,0 @@ -for(i = 0; 100 > i; i++) -{ - console.log(i); - - if((i) % 3 == 0 && (i) % 5 == 0) - { console.log("- FizzBuzz"); } - - else if((i) % 3 == 0) - { console.log("- Fizz"); } - - else if((i) % 5 == 0) - { console.log("- Buzz"); } - - console.log("\n"); -} From 593f943784f8fbda5b3a9e33fc67dd9e880d243f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:14:14 -0300 Subject: [PATCH 14/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=206=20-=20M=C3=A1?= =?UTF-8?q?ximo=20e=20M=C3=ADnimo.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5cio 6 - M\303\241ximo e M\303\255nimo.js" | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 "Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" diff --git "a/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" "b/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" deleted file mode 100644 index f76fccb..0000000 --- "a/Exerc\303\255cio 6 - M\303\241ximo e M\303\255nimo.js" +++ /dev/null @@ -1,21 +0,0 @@ - -var num1 = prompt("Número 1:"); -var num2 = prompt("Número 2:"); - -//calcula minimo -function calculaMinimo(num1, num2) -{ - if(num1 > num2) { return num2; } - else { return num1; } -} - -//calcula maximo -function calculaMaximo(num1, num2) -{ - if(num1 > num2) { return num1; } - else { return num2; } -} - -//resultado e chamada da funcao -console.log("Menor número: "+ calculaMinimo(num1, num2)); -console.log("Maior número: "+ calculaMaximo(num1, num2)); \ No newline at end of file From fb2508e90fe6f27128f70f4bccb7b9c80cf9c2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:14:26 -0300 Subject: [PATCH 15/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=207=20-=20Modulo.?= =?UTF-8?q?js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 7 - Modulo.js" | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 "Exerc\303\255cio 7 - Modulo.js" diff --git "a/Exerc\303\255cio 7 - Modulo.js" "b/Exerc\303\255cio 7 - Modulo.js" deleted file mode 100644 index fc92804..0000000 --- "a/Exerc\303\255cio 7 - Modulo.js" +++ /dev/null @@ -1,16 +0,0 @@ -var num1 = prompt("Número:"); - -function mod2(number) -{ - if((number) % 2 == 0) - { return true; } - else { return false; } -} - -//resultado e chamada da funcao - -if((mod2(num1))==false) -{ console.log("o numero nao é divisivel por 2"); } - -else if((mod2(num1))== true) -{ console.log("o numero nao é divisivel por 2"); } \ No newline at end of file From 3ad235337d6157bd6f225f264e37940c82c45cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:14:36 -0300 Subject: [PATCH 16/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=208=20-=20Modulo?= =?UTF-8?q?=20e=20Recursividade.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\303\255cio 8 - Modulo e Recursividade.js" | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 "Exerc\303\255cio 8 - Modulo e Recursividade.js" diff --git "a/Exerc\303\255cio 8 - Modulo e Recursividade.js" "b/Exerc\303\255cio 8 - Modulo e Recursividade.js" deleted file mode 100644 index 1a087fd..0000000 --- "a/Exerc\303\255cio 8 - Modulo e Recursividade.js" +++ /dev/null @@ -1,19 +0,0 @@ -var num1 = prompt("Número:"); -var mod1 = prompt("Modulo:"); - -function mod(number, modinicio) -{ - if(number >= modinicio){ return mod(number - modinicio, modinicio); } - - if(number == 0) { return true; } - - else { return false; } -} - -//resultado e chamada da funcao - -if(mod(num1, mod1)== false) -{ console.log(" Não é Divisivel por " + mod1); } - -else if(mod(num1, mod1)== true) -{ console.log(" É Divisivel por " + mod1); } From f910f2b8f1cfc84bae9c96d859c35dabb77c16ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:15:37 -0300 Subject: [PATCH 17/27] =?UTF-8?q?Delete=20Exerc=C3=ADcio=209=20-Caracteres?= =?UTF-8?q?.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Exerc\303\255cio 9 -Caracteres.js" | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 "Exerc\303\255cio 9 -Caracteres.js" diff --git "a/Exerc\303\255cio 9 -Caracteres.js" "b/Exerc\303\255cio 9 -Caracteres.js" deleted file mode 100644 index 596dabf..0000000 --- "a/Exerc\303\255cio 9 -Caracteres.js" +++ /dev/null @@ -1,20 +0,0 @@ -var char = prompt("Cactere:"); -var string = prompt("String:"); - -function countChars(frase, char) -{ - var aparece = 0; - var tamanhostring = frase.length-1 - - for(i = 0; tamanhostring > i; i++) - { - if(char == frase[i]) - { - aparece++; - } - } - return aparece; -} - -//resultado e chamada da funcao -console.log(" O caractere " + char + " aparece " + countChars(string,char) + " vezes"); From 43f1da3f211d5f113647bb01cafe2d458dc18d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:35:53 -0300 Subject: [PATCH 18/27] Create Triangulo.js --- "Parte 1 - Conceitos B\303\241sicos/Triangulo.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "Parte 1 - Conceitos B\303\241sicos/Triangulo.js" diff --git "a/Parte 1 - Conceitos B\303\241sicos/Triangulo.js" "b/Parte 1 - Conceitos B\303\241sicos/Triangulo.js" new file mode 100644 index 0000000..0a753c0 --- /dev/null +++ "b/Parte 1 - Conceitos B\303\241sicos/Triangulo.js" @@ -0,0 +1,15 @@ +var qntdelinhas = prompt("Digite um tamanho p/ o triangulo ser criado:"); + +var numporlinha=2; + +//para a quantidade de linhas que o usuário quer +for(i = 0; qntdelinhas > i; i++) +{ + //para cada linha + for(j = 0; j < numporlinha; j++) + { + console.log("#"); + } + console.log("\n"); + numporlinha++; +} From 6b0a9e8c131d8d71015fb4ab950f1809140f68a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:36:19 -0300 Subject: [PATCH 19/27] Add files via upload --- .../Exercicio 4 - Numeros de 1 a 100.js" | 15 ++++++++++++++ .../Exerc\303\255cio 2 - Xadrez.js" | 16 +++++++++++++++ .../Exerc\303\255cio 3 - Palindromo.js" | 20 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 "Parte 1 - Conceitos B\303\241sicos/Exercicio 4 - Numeros de 1 a 100.js" create mode 100644 "Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 2 - Xadrez.js" create mode 100644 "Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 3 - Palindromo.js" diff --git "a/Parte 1 - Conceitos B\303\241sicos/Exercicio 4 - Numeros de 1 a 100.js" "b/Parte 1 - Conceitos B\303\241sicos/Exercicio 4 - Numeros de 1 a 100.js" new file mode 100644 index 0000000..f35f1f4 --- /dev/null +++ "b/Parte 1 - Conceitos B\303\241sicos/Exercicio 4 - Numeros de 1 a 100.js" @@ -0,0 +1,15 @@ +for(i = 0; 100 > i; i++) +{ + console.log(i); + + if((i) % 3 == 0 && (i) % 5 == 0) + { console.log("- FizzBuzz"); } + + else if((i) % 3 == 0) + { console.log("- Fizz"); } + + else if((i) % 5 == 0) + { console.log("- Buzz"); } + + console.log("\n"); +} \ No newline at end of file diff --git "a/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 2 - Xadrez.js" "b/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 2 - Xadrez.js" new file mode 100644 index 0000000..570dae7 --- /dev/null +++ "b/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 2 - Xadrez.js" @@ -0,0 +1,16 @@ +for(j = 0; j < 8; j++) +{ + for(i = 0; i < 8; i++) + { + //para cada linha + if((i + j) % 2 == 0) + { + console.log("#"); + } + else + { + console.log(" "); + } + } + console.log("\n"); +} \ No newline at end of file diff --git "a/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 3 - Palindromo.js" "b/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 3 - Palindromo.js" new file mode 100644 index 0000000..d848e0a --- /dev/null +++ "b/Parte 1 - Conceitos B\303\241sicos/Exerc\303\255cio 3 - Palindromo.js" @@ -0,0 +1,20 @@ +var palindromo = prompt("Digite um palíndromo:"); + +var tampalindromo = palindromo.length; + +var resultado = true; +//para a quantidade de linhas que o usuário quer +for(i = 0; tampalindromo > i; i++) +{ + //para cada letra + if(palindromo[i] != palindromo[tampalindromo-1]) + { + resultado = false; + break; + } + else + { tampalindromo--;} +} +if(resultado == true){ console.log("É um palíndromo. "); } + +else { console.log("Não é um palíndromo. "); } From 38b917e0230fcabf9503b9172b38ac1de4755195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:36:50 -0300 Subject: [PATCH 20/27] Create a --- Parte 2 - Funcoes/a | 1 + 1 file changed, 1 insertion(+) create mode 100644 Parte 2 - Funcoes/a diff --git a/Parte 2 - Funcoes/a b/Parte 2 - Funcoes/a new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Parte 2 - Funcoes/a @@ -0,0 +1 @@ + From 0b2b59f1679ec36905524541bfa5fc5dbf8a14be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:42:13 -0300 Subject: [PATCH 21/27] Add files via upload --- ...5cio 5 - M\303\241ximo e M\303\255nimo.js" | 21 +++++++++++++++++++ .../Exerc\303\255cio 6 e 7 - Modulo.js" | 16 ++++++++++++++ .../Exerc\303\255cio 9 -Caracteres.js" | 20 ++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 "Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" create mode 100644 "Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" create mode 100644 "Parte 2 - Funcoes/Exerc\303\255cio 9 -Caracteres.js" diff --git "a/Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" "b/Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" new file mode 100644 index 0000000..f76fccb --- /dev/null +++ "b/Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" @@ -0,0 +1,21 @@ + +var num1 = prompt("Número 1:"); +var num2 = prompt("Número 2:"); + +//calcula minimo +function calculaMinimo(num1, num2) +{ + if(num1 > num2) { return num2; } + else { return num1; } +} + +//calcula maximo +function calculaMaximo(num1, num2) +{ + if(num1 > num2) { return num1; } + else { return num2; } +} + +//resultado e chamada da funcao +console.log("Menor número: "+ calculaMinimo(num1, num2)); +console.log("Maior número: "+ calculaMaximo(num1, num2)); \ No newline at end of file diff --git "a/Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" "b/Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" new file mode 100644 index 0000000..fc92804 --- /dev/null +++ "b/Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" @@ -0,0 +1,16 @@ +var num1 = prompt("Número:"); + +function mod2(number) +{ + if((number) % 2 == 0) + { return true; } + else { return false; } +} + +//resultado e chamada da funcao + +if((mod2(num1))==false) +{ console.log("o numero nao é divisivel por 2"); } + +else if((mod2(num1))== true) +{ console.log("o numero nao é divisivel por 2"); } \ No newline at end of file diff --git "a/Parte 2 - Funcoes/Exerc\303\255cio 9 -Caracteres.js" "b/Parte 2 - Funcoes/Exerc\303\255cio 9 -Caracteres.js" new file mode 100644 index 0000000..8135443 --- /dev/null +++ "b/Parte 2 - Funcoes/Exerc\303\255cio 9 -Caracteres.js" @@ -0,0 +1,20 @@ +var char = prompt("Cactere:"); +var string = prompt("String:"); + +function ContaCactere(string, char) +{ + var aparece = 0; + var tamanhostring = string.length-1 + + for(i = 0; tamanhostring > i; i++) + { + if(char == string[i]) + { + aparece++; + } + } + return aparece; +} + +//resultado e chamada da funcao +console.log(" O caractere " + char + " aparece " + ContaCactere(string,char) + " vezes"); From 2891710049cd3fb0c2ce95a7be3fe87f6f1c536c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:43:42 -0300 Subject: [PATCH 22/27] =?UTF-8?q?Rename=20Exerc=C3=ADcio=206=20e=207=20-?= =?UTF-8?q?=20Modulo.js=20to=20Exerc=C3=ADcio=207=20e=208=20-=20Modulo.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exerc\303\255cio 7 e 8 - Modulo.js" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" => "Parte 2 - Funcoes/Exerc\303\255cio 7 e 8 - Modulo.js" (83%) diff --git "a/Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" "b/Parte 2 - Funcoes/Exerc\303\255cio 7 e 8 - Modulo.js" similarity index 83% rename from "Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" rename to "Parte 2 - Funcoes/Exerc\303\255cio 7 e 8 - Modulo.js" index fc92804..fee2cc9 100644 --- "a/Parte 2 - Funcoes/Exerc\303\255cio 6 e 7 - Modulo.js" +++ "b/Parte 2 - Funcoes/Exerc\303\255cio 7 e 8 - Modulo.js" @@ -13,4 +13,4 @@ if((mod2(num1))==false) { console.log("o numero nao é divisivel por 2"); } else if((mod2(num1))== true) -{ console.log("o numero nao é divisivel por 2"); } \ No newline at end of file +{ console.log("o numero nao é divisivel por 2"); } From 628f15529fc0ab1ee106dec527a45e8d7a57c23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:44:07 -0300 Subject: [PATCH 23/27] =?UTF-8?q?Rename=20Exerc=C3=ADcio=205=20-=20M=C3=A1?= =?UTF-8?q?ximo=20e=20M=C3=ADnimo.js=20to=20Exerc=C3=ADcio=205=20e=206=20-?= =?UTF-8?q?=20M=C3=A1ximo=20e=20M=C3=ADnimo.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exerc\303\255cio 5 e 6 - M\303\241ximo e M\303\255nimo.js" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" => "Parte 2 - Funcoes/Exerc\303\255cio 5 e 6 - M\303\241ximo e M\303\255nimo.js" (87%) diff --git "a/Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" "b/Parte 2 - Funcoes/Exerc\303\255cio 5 e 6 - M\303\241ximo e M\303\255nimo.js" similarity index 87% rename from "Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" rename to "Parte 2 - Funcoes/Exerc\303\255cio 5 e 6 - M\303\241ximo e M\303\255nimo.js" index f76fccb..f1a935e 100644 --- "a/Parte 2 - Funcoes/Exerc\303\255cio 5 - M\303\241ximo e M\303\255nimo.js" +++ "b/Parte 2 - Funcoes/Exerc\303\255cio 5 e 6 - M\303\241ximo e M\303\255nimo.js" @@ -18,4 +18,4 @@ function calculaMaximo(num1, num2) //resultado e chamada da funcao console.log("Menor número: "+ calculaMinimo(num1, num2)); -console.log("Maior número: "+ calculaMaximo(num1, num2)); \ No newline at end of file +console.log("Maior número: "+ calculaMaximo(num1, num2)); From d7db6d386a4b1ac322c70204b7e35f467a77cd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:45:15 -0300 Subject: [PATCH 24/27] Create a --- Parte 3 - Objetos e Array/a | 1 + 1 file changed, 1 insertion(+) create mode 100644 Parte 3 - Objetos e Array/a diff --git a/Parte 3 - Objetos e Array/a b/Parte 3 - Objetos e Array/a new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/Parte 3 - Objetos e Array/a @@ -0,0 +1 @@ +a From 396831930c880277fd5c76f9e0ebf51cd6c9c84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:46:01 -0300 Subject: [PATCH 25/27] Add files via upload --- .../Exerc\303\255cio 10 - Range.js" | 15 ++++++++++ ...Exerc\303\255cio 11 - Range + variacao.js" | 18 +++++++++++ .../Exerc\303\255cio 12 - ReverseArray.js" | 14 +++++++++ .../Exerc\303\255cio 13 - Lista.js" | 11 +++++++ .../Exerc\303\255cio 14 - DeepEquals.js" | 30 +++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 "Parte 3 - Objetos e Array/Exerc\303\255cio 10 - Range.js" create mode 100644 "Parte 3 - Objetos e Array/Exerc\303\255cio 11 - Range + variacao.js" create mode 100644 "Parte 3 - Objetos e Array/Exerc\303\255cio 12 - ReverseArray.js" create mode 100644 "Parte 3 - Objetos e Array/Exerc\303\255cio 13 - Lista.js" create mode 100644 "Parte 3 - Objetos e Array/Exerc\303\255cio 14 - DeepEquals.js" diff --git "a/Parte 3 - Objetos e Array/Exerc\303\255cio 10 - Range.js" "b/Parte 3 - Objetos e Array/Exerc\303\255cio 10 - Range.js" new file mode 100644 index 0000000..04698f1 --- /dev/null +++ "b/Parte 3 - Objetos e Array/Exerc\303\255cio 10 - Range.js" @@ -0,0 +1,15 @@ +var min = prompt("Digite o mínimo:"); +var max = prompt("Digite o maximo:"); + +function range(min, max) +{ + var intervalo = [max-min]; + var j = 0; + for(i = min; max >= i; i++) + { + intervalo[j]= i; + j++ + } + return intervalo; +} +console.log(range(min,max)); \ No newline at end of file diff --git "a/Parte 3 - Objetos e Array/Exerc\303\255cio 11 - Range + variacao.js" "b/Parte 3 - Objetos e Array/Exerc\303\255cio 11 - Range + variacao.js" new file mode 100644 index 0000000..138aa0e --- /dev/null +++ "b/Parte 3 - Objetos e Array/Exerc\303\255cio 11 - Range + variacao.js" @@ -0,0 +1,18 @@ +var min = prompt("Digite o mínimo:"); +var max = prompt("Digite o maximo:"); +var variacao = prompt("Digite a variação:"); + +function range(min, max, variacao) +{ + var intervalo = []; + var j = 0; + + for(i = min; max >= i; i = (i + variacao)) + { + intervalo[j] = i; + j++; + } + return intervalo; +} + +console.log(range(min,max,variacao)); \ No newline at end of file diff --git "a/Parte 3 - Objetos e Array/Exerc\303\255cio 12 - ReverseArray.js" "b/Parte 3 - Objetos e Array/Exerc\303\255cio 12 - ReverseArray.js" new file mode 100644 index 0000000..692f6ad --- /dev/null +++ "b/Parte 3 - Objetos e Array/Exerc\303\255cio 12 - ReverseArray.js" @@ -0,0 +1,14 @@ +function reverseArray(array) +{ + var reverso = []; + var j = 1; + + for(i = 0; i <= array.length; i++) + { reverso[i] = array[array.length - j]; + j++; + } + + return reverso; +} +var array = [0,1,2,3,4,5,6,7,8,9]; +console.log(reverseArray(array)); \ No newline at end of file diff --git "a/Parte 3 - Objetos e Array/Exerc\303\255cio 13 - Lista.js" "b/Parte 3 - Objetos e Array/Exerc\303\255cio 13 - Lista.js" new file mode 100644 index 0000000..5ffc5ae --- /dev/null +++ "b/Parte 3 - Objetos e Array/Exerc\303\255cio 13 - Lista.js" @@ -0,0 +1,11 @@ +function toList(array) +{ + var list = null; + for (var i = array.length - 1; i >= 0; i--) { + list = { value: array[i], rest: list }; + } + return list; + } + +var array = [0,1,2,3,4,5,6,7,8,9]; +console.log(toList(array)); \ No newline at end of file diff --git "a/Parte 3 - Objetos e Array/Exerc\303\255cio 14 - DeepEquals.js" "b/Parte 3 - Objetos e Array/Exerc\303\255cio 14 - DeepEquals.js" new file mode 100644 index 0000000..26e90f9 --- /dev/null +++ "b/Parte 3 - Objetos e Array/Exerc\303\255cio 14 - DeepEquals.js" @@ -0,0 +1,30 @@ +var objetoTeste = { + idade: 11, + nome: "Joao" +} +var objetoTeste2 = { + idade: 20, + nome: " Joao" +} + +function deepEquals(objteste1, objteste2){ + + var tmp = []; + for (var prop in objteste1) + { tmp.push(prop); } + + var tmp2 = []; + for (var prop in objteste2) + { tmp2.push(prop); } + + if(JSON.stringify(tmp) == JSON.stringify(tmp2)) + { return true; } + else { return false; } +} +//resultado e chamada da funcao + +if(deepEquals(objetoTeste, objetoTeste2) == false) +{ console.log("Os objetos nao sao iguais"); } + +else if(deepEquals(objetoTeste, objetoTeste2) == true) +{ console.log("Os objetos sao iguais"); } \ No newline at end of file From 40e463f61e8f3c2339325afc2be60c57f4ef01ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:47:38 -0300 Subject: [PATCH 26/27] Create a --- Parte 4 - Funcoes de Alta Ordem/a | 1 + 1 file changed, 1 insertion(+) create mode 100644 Parte 4 - Funcoes de Alta Ordem/a diff --git a/Parte 4 - Funcoes de Alta Ordem/a b/Parte 4 - Funcoes de Alta Ordem/a new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/Parte 4 - Funcoes de Alta Ordem/a @@ -0,0 +1 @@ +a From ce9eb29d591f9fbd18afe8ff9590dcd18f3c0a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Le=C3=A3o?= <104568516+juliaaliceleao@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:48:07 -0300 Subject: [PATCH 27/27] Add files via upload --- ...03\255cio 15 - Ordena\303\247\303\243o.js" | 79 +++++++++++++++++++ .../Exerc\303\255cio 16 - Criptografia.js" | 24 ++++++ ...erc\303\255cio 17 - Verificando Numero.js" | 26 ++++++ ...3\255cio 18 - Transformacoes em String.js" | 37 +++++++++ ...erc\303\255cio 19 - Funcoes Matriciais.js" | 33 ++++++++ 5 files changed, 199 insertions(+) create mode 100644 "Parte 4 - Funcoes de Alta Ordem/Exec\303\255cio 15 - Ordena\303\247\303\243o.js" create mode 100644 "Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 16 - Criptografia.js" create mode 100644 "Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 17 - Verificando Numero.js" create mode 100644 "Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 18 - Transformacoes em String.js" create mode 100644 "Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 19 - Funcoes Matriciais.js" diff --git "a/Parte 4 - Funcoes de Alta Ordem/Exec\303\255cio 15 - Ordena\303\247\303\243o.js" "b/Parte 4 - Funcoes de Alta Ordem/Exec\303\255cio 15 - Ordena\303\247\303\243o.js" new file mode 100644 index 0000000..675aa72 --- /dev/null +++ "b/Parte 4 - Funcoes de Alta Ordem/Exec\303\255cio 15 - Ordena\303\247\303\243o.js" @@ -0,0 +1,79 @@ +var array = [1, 2, 3, 4, 5]; + +function bubbleSort(vetor, criterio) +{ + var tamanho = vetor.length; + for (var i = 0; i < tamanho - 1; i++) { + for (var j = 0; j < tamanho - i - 1; j++) { + if (criterio(vetor[j], vetor[j + 1])) { + var temp = vetor[j]; + vetor[j] = vetor[j + 1]; + vetor[j + 1] = temp; + } + } + } + return vetor; +} + +function crescente(a, b) { + return a > b; +} + +function decrescente(a, b) { + return a < b; +} + +function crescenteImpares(a, b) { + if (a % 2 == 0 && b % 2 != 0) { + return false; + } else if (a % 2 != 0 && b % 2 == 0) { + return true; + } else { + return a > b; + } +} + +function decrescenteImpares(a, b) { + if (a % 2 == 0 && b % 2 != 0) { + return true; + } else if (a % 2 != 0 && b % 2 == 0) { + return false; + } else { + return a < b; + } +} + +function crescentePares(vetor) { + var pares = vetor.filter(function(elemento) { + return elemento % 2 == 0; + }); + return bubbleSort(pares, crescente); +} + +function decrescentePares(vetor) { + var pares = vetor.filter(function(elemento) { + return elemento % 2 == 0; + }); + return bubbleSort(pares, decrescente); +} + +var vetor = [10, 4, 8, 2, 6, 7, 3, 1, 5, 9]; +console.log("Vetor: ", vetor); + +var vetorCrescente = bubbleSort(vetor.slice(), crescente); +console.log("Ordenado em ordem crescente: ", vetorCrescente); + +var vetorDecrescente = bubbleSort(vetor.slice(), decrescente); +console.log("Ordenado em ordem decrescente: ", vetorDecrescente); + +var vetorCrescenteImpares = bubbleSort(vetor.slice(), crescenteImpares); +console.log("Ordenado em ordem crescente, com ímpares antes dos pares: ", vetorCrescenteImpares); + +var vetorDecrescenteImpares = bubbleSort(vetor.slice(), decrescenteImpares); +console.log("Ordenado em ordem decrescente, com pares antes dos ímpares: ", vetorDecrescenteImpares); + +var vetorCrescentePares = crescentePares(vetor); +console.log("Ordenado em ordem crescente, apenas os pares: ", vetorCrescentePares); + +var vetorDecrescentePares = decrescentePares(vetor); +console.log("Ordenado em ordem decrescente, apenas os pares: ", vetorDecrescentePares); diff --git "a/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 16 - Criptografia.js" "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 16 - Criptografia.js" new file mode 100644 index 0000000..fa63fb6 --- /dev/null +++ "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 16 - Criptografia.js" @@ -0,0 +1,24 @@ +function cifraCesar(frase, criterio) +{ + var criptografada = ""; + var tmp = frase.toLowerCase(); + + for(i = 0; i < frase.length; i++) + { + var caractere = tmp.charCodeAt(i); + if (caractere >= 65 && caractere <= 90) + { criptografada += String.fromCharCode((caractere - 65 + criterio) % 26 + 65); } + + else if (caractere >= 97 && caractere <= 122) + { criptografada += String.fromCharCode((caractere - 97 + criterio) % 26 + 97); } + + else { criptografada += tmp.charAt(i); } + } + + return criptografada; +} + +var frase = "Teste para criptografia"; +var criterio = 3; +console.log("Frase: "+ frase); +console.log("Frase Criptografada: " + cifraCesar(frase, criterio)); \ No newline at end of file diff --git "a/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 17 - Verificando Numero.js" "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 17 - Verificando Numero.js" new file mode 100644 index 0000000..f0255d7 --- /dev/null +++ "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 17 - Verificando Numero.js" @@ -0,0 +1,26 @@ +function verificarNumero(numero, funcaoVerificacao) +{ return funcaoVerificacao(numero); } + + function Impar(numero) + { return numero % 2 !== 0; } + + function Primo(numero) { + if (numero <= 1) { + return false; + } + + for (var i = 2; i <= Math.sqrt(numero); i++) { + if (numero % i === 0) { + return false; + } + } + + return true; + } + + console.log("13=Impar? " + verificarNumero(13, Impar)); // true + console.log("2=Impar? " + verificarNumero(2, Impar)); // false + + console.log("5=Primo? " + verificarNumero(5, Primo)); // true + console.log("6=Primo? " + verificarNumero(6, Primo)); // false + \ No newline at end of file diff --git "a/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 18 - Transformacoes em String.js" "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 18 - Transformacoes em String.js" new file mode 100644 index 0000000..6d2bc71 --- /dev/null +++ "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 18 - Transformacoes em String.js" @@ -0,0 +1,37 @@ +function transformString(string, Funcao) { + const vowels = ['a', 'e', 'i', 'o', 'u']; + transformedStr = ''; + for (i = 0; i < string.length; i++) { + char = string.charAt(i); + if (vowels.includes(char.toLowerCase())) { + transformedStr += Funcao(char, true); + } else { + transformedStr += Funcao(char, false); + } + } + return transformedStr; + } + + function uppercaseVowelsOrConsonants(char, isVowel) { + if (isVowel) { + return char.toUpperCase(); + } else { + return char.toLowerCase(); + } + } + + function lowercaseVowelsOrConsonants(char, isVowel) { + if (isVowel) { + return char.toLowerCase(); + } else { + return char.toUpperCase(); + } + } + + var string = 'bom dia'; + console.log("String original: " + string); + console.log("Caixa alta nas vogais: " + transformString(string, uppercaseVowelsOrConsonants)); + console.log("Caixa alta nas consoantes: " + transformString(string, (char, isVowel) => isVowel ? char.toLowerCase() : char.toUpperCase())); + console.log("Caixa baixa nas vogais: " + transformString(string, lowercaseVowelsOrConsonants)); + console.log("Caixa baixa nas consoantes: " + transformString(string, (char, isVowel) => isVowel ? char.toUpperCase() : char.toLowerCase())); + \ No newline at end of file diff --git "a/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 19 - Funcoes Matriciais.js" "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 19 - Funcoes Matriciais.js" new file mode 100644 index 0000000..91d867a --- /dev/null +++ "b/Parte 4 - Funcoes de Alta Ordem/Exerc\303\255cio 19 - Funcoes Matriciais.js" @@ -0,0 +1,33 @@ +function criarMatriz(linhas, colunas, funcaoescolhida) +{ + var matriz = []; + for (i = 0; i < linhas; i++) { + var linha = []; + for (j = 0; j < colunas; j++) { + linha.push(funcaoescolhida(i, j)); + } + matriz.push(linha); + } + return matriz; + } + +function soma(i, j) +{ return i + j; } + +function produto(i, j) +{ return i * j; } + +function igual(i, j) +{ return i == j ? 1 : 0; } + +function divisao(i, j) +{ return i ** 2 / (j + 1); } + +function maiorOuMenor(i, j) +{ return i > j ? 1 : (i < j ? 5 : 0); } + + console.log(criarMatriz(3, 3, somaIndices)); + console.log(criarMatriz(3, 3, produtoIndices)); + console.log(criarMatriz(3, 3, identidade)); + console.log(criarMatriz(3, 3, divisaoIndices)); + console.log(criarMatriz(3, 3, maiorOuMenor)); \ No newline at end of file