diff --git a/.project b/.project index 700a32c79..e99782d96 100644 --- a/.project +++ b/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + 1676329080234 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..f9fe34593 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.vscode/launch.json b/.vscode/launch.json index ac11c09b2..7cc11d69b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,12 @@ { "configurations": [ + { + "type": "java", + "name": "Launch App", + "request": "launch", + "mainClass": "com.dsa.app.App", + "projectName": "my-app" + }, { "type": "java", "name": "Launch App", diff --git a/cspell.json b/cspell.json new file mode 100644 index 000000000..91f049a20 --- /dev/null +++ b/cspell.json @@ -0,0 +1,9 @@ +{ + "version": "0.2", + "ignorePaths": ["src"], + "dictionaryDefinitions": [], + "dictionaries": [], + "words": [], + "ignoreWords": [], + "import": [] +} diff --git a/src/main/java/com/dsa/app/AnioBisiesto.java b/src/main/java/com/dsa/app/AnioBisiesto.java new file mode 100644 index 000000000..b4101b266 --- /dev/null +++ b/src/main/java/com/dsa/app/AnioBisiesto.java @@ -0,0 +1,7 @@ +package com.dsa.app; + +public class AnioBisiesto{ + public static boolean esBisiesto(int anio){ + return (anio % 4 == 0 && anio % 400 == 0); + } +} \ No newline at end of file diff --git a/src/main/java/com/dsa/app/App.java b/src/main/java/com/dsa/app/App.java new file mode 100644 index 000000000..4b37779dd --- /dev/null +++ b/src/main/java/com/dsa/app/App.java @@ -0,0 +1,21 @@ +/*---------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for license information. + *---------------------------------------------------------------------------------------*/ + +package com.dsa.app; + +public class App { + public static void main(String[] args) { + // System.out.println("Hello Remote World!"); + // System.out.println(Factorial.getFactorial(5)); + // System.out.println(NumeroFuerte.esNumeroFuerte(145)); + // System.out.println(Primo.esPrimo(4)); + // StarLadder.buildLadder(5); + Racional a = new Racional(7,9); + Racional suma = a.suma(new Racional(7,8)); + System.out.println(suma.getString()); + // a.getString(); + + } +} \ No newline at end of file diff --git a/src/main/java/com/dsa/app/Factorial.java b/src/main/java/com/dsa/app/Factorial.java new file mode 100644 index 000000000..e498f93fc --- /dev/null +++ b/src/main/java/com/dsa/app/Factorial.java @@ -0,0 +1,14 @@ +package com.dsa.app; + + +public class Factorial { + public static int getFactorial(int n){ + if(n < 1){throw new Error();} + int i = 1, fact = 1; + while(i<=n){ + fact *= i; + i++; + } + return fact; + } +} \ No newline at end of file diff --git a/src/main/java/com/dsa/app/NumeroFuerte.java b/src/main/java/com/dsa/app/NumeroFuerte.java new file mode 100644 index 000000000..22956cda6 --- /dev/null +++ b/src/main/java/com/dsa/app/NumeroFuerte.java @@ -0,0 +1,15 @@ +package com.dsa.app; + +/** + * NumeroFuerte + */ +public class NumeroFuerte { + public static boolean esNumeroFuerte(int n){ + int original = n, sum = 0; + while(n >= 1){ + sum += Factorial.getFactorial(n%10); + n /= 10; + } + return original == sum; + } +} \ No newline at end of file diff --git a/src/main/java/com/dsa/app/Primo.java b/src/main/java/com/dsa/app/Primo.java new file mode 100644 index 000000000..4f4d29741 --- /dev/null +++ b/src/main/java/com/dsa/app/Primo.java @@ -0,0 +1,14 @@ +package com.dsa.app; + +public class Primo { + public static boolean esPrimo(int n){ + int i = 2; + if(n < i){return false;} + while(i < n/2+1 ){ + if(n % i == 0) + return false; + i++; + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/dsa/app/Racional.java b/src/main/java/com/dsa/app/Racional.java new file mode 100644 index 000000000..e9a8c4c04 --- /dev/null +++ b/src/main/java/com/dsa/app/Racional.java @@ -0,0 +1,27 @@ +package com.dsa.app; + +public class Racional { + int num; + int den; + public Racional(){ + this.num = 1; + this.den = 1; + } + public Racional(int num, int den){ + this.num = num; + this.den = den; + } + + public Racional suma(Racional a){ + return new Racional(this.num*a.den + this.den*a.num, this.den*a.den); + } + + public static Racional resta(Racional a, Racional b){ + return new Racional(a.num*b.den - a.den * b.num, a.den * b.den); + } + + public String getString(){ + String string = new String(this.num + "/" + this.den); + return string; + } +} diff --git a/src/main/java/com/dsa/app/StarLadder.java b/src/main/java/com/dsa/app/StarLadder.java new file mode 100644 index 000000000..41772265b --- /dev/null +++ b/src/main/java/com/dsa/app/StarLadder.java @@ -0,0 +1,39 @@ +package com.dsa.app; + +public class StarLadder { + public static void buildLadder(int n){ + for (int i = 0; i < n; i++) { + for (int j = 0; j < n-i; j++) { + System.out.print("*"); + } + System.out.println(); + } + + for (int i = 0; i < n; i++) { + for (int j = 1; j < n-i; j++) { + System.out.print(" "); + } + for (int j = 0; j < i+1; j++) { + System.out.print("*"); + } + System.out.println(); + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < i+1; j++) { + System.out.print("*"); + } + System.out.println(); + } + + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + System.out.print(" "); + } + for (int j = 0; j < n-i; j++) { + System.out.print("*"); + } + System.out.println(); + } + } +} diff --git a/src/main/java/com/mycompany/app/App.java b/src/main/java/com/mycompany/app/App.java deleted file mode 100644 index bc1164c88..000000000 --- a/src/main/java/com/mycompany/app/App.java +++ /dev/null @@ -1,12 +0,0 @@ -/*---------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See LICENSE in the project root for license information. - *---------------------------------------------------------------------------------------*/ - -package com.mycompany.app; - -public class App { - public static void main(String[] args) { - System.out.println("Hello Remote World!"); - } -}