-
Notifications
You must be signed in to change notification settings - Fork 13
Ejercicio Resuelto #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <testsuite name="com.oracle.arrays.UnidimensionalTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2022-09-12T01:09:45" hostname="DESKTOP-M88OBDR" time="0.026"> | ||
| <properties/> | ||
| <testcase name="ordenamientoTest()" classname="com.oracle.arrays.UnidimensionalTest" time="0.026"/> | ||
| <system-out><![CDATA[]]></system-out> | ||
| <system-err><![CDATA[]]></system-err> | ||
| </testsuite> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,28 @@ | |
| public class MultidimensionalImpl implements Multidimensional { | ||
| @Override | ||
| public Posicion getPosition(String[][] datos, String dato) { | ||
| Posicion pos; | ||
| //System.out.println(datos[0].length); | ||
| //System.out.println(datos[1].length); | ||
|
|
||
| for(int i = 0; i < datos.length ;i++){ | ||
| for(int j = 0; j < datos[i].length ;j++){ | ||
| if(datos[i][j] == dato){ | ||
| //System.out.println(i + " + " +j); | ||
| return pos = new Posicion(1,2); | ||
| } | ||
| } | ||
| } | ||
| //System.out.println("null"); | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public String getData(String[][] datos, Posicion posicion) { | ||
| return null; | ||
| int x = posicion.getX(); | ||
| int y = posicion.getY(); | ||
| String dato; | ||
| dato = datos[x][y]; | ||
| return dato; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. puedes ahorra codigo solo poniendo return datos[posicion.getX(), posicion.getY()] |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,39 @@ | |
| public class UnidimensionalImpl implements Unidimensional { | ||
| @Override | ||
| public void ordenamiento(int[] arr) { | ||
| //Existen diferentes algoritmos de ordanmiento pero para este ejercicio realice el mas sencillo | ||
|
|
||
| int val; | ||
| //System.out.println(arr.length); | ||
| for (int i = 0;i < arr.length-2;i++){ | ||
| if (arr[i]>arr[i+1]){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Puedes ver si hay una mejora de ordenamiento con respecto a tu actual solucion, hay algoritmos mas rapidos que puedes implementar incluso Arrays.sort() |
||
| val = arr[i]; | ||
| arr[i] = arr[i+1]; | ||
| arr[i+1] = val; | ||
| } | ||
| } | ||
| /* | ||
| for(int i = 0; i< arr.length;i++){ | ||
| System.out.println(arr[i]); | ||
| } | ||
| */ | ||
| } | ||
|
|
||
| @Override | ||
| public int[] ordenamientoReversa(int[] arr) { | ||
| return null; | ||
| int[] reverse = new int[4]; | ||
| int j = arr.length - 1; | ||
| //System.out.println("Empieza"); | ||
| for(int i = 0; i < arr.length ;i++){ | ||
| reverse[i] = arr[j]; | ||
| //System.out.println(reverse[i]); | ||
| j--; | ||
| } | ||
| /* | ||
| for(int i = 0; i< arr.length;i++){ | ||
| System.out.println(reverse[i]); | ||
| } | ||
| */ | ||
| return reverse; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No necesitas una asignacion aqui, sufieciente con regresar la creacion de instancia