diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..37e0fa4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense para saber los atributos posibles. + // Mantenga el puntero para ver las descripciones de los existentes atributos. + // Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "Sumatoria", + "request": "launch", + "mainClass": "Sumatoria", + "projectName": "Java-2023_e7000a08" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 126220d..6a5041c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ +[![Greetings](https://github.com/digitalers/Java-2023/actions/workflows/greetings.yml/badge.svg?branch=main)](https://github.com/digitalers/Java-2023/actions/workflows/greetings.yml) + # Java-2023 + Repositorio del programa de formación gratuita en desarrollo de software y oficios digitales [Java Full Stack] diff --git a/Sumatoria.java b/Sumatoria.java new file mode 100644 index 0000000..8530357 --- /dev/null +++ b/Sumatoria.java @@ -0,0 +1,30 @@ +public class Sumatoria { + public static void main (String[] args) { + Integer numeros[] = {6,7,5,4,3,1,2,3,5,6,7,9,0,0,1,2,4,1,2,3,5,1,2}; + suman(numeros); + } + + public static void suman(Integer[] array) { + + int sum = 0; + int i = 0; + + while (i < array.length ) { + sum = array[i]; + + for (int f = i+1; f < array.length ; f++) { + sum += array[f]; + + if (sum == 13) { + System.out.printf("Loss elementos entre (%d, %d) suman 13\n", i , f); + break; + } else if (sum > 13) { + break; + } + + } + i++; + } + } + +} \ No newline at end of file