Skip to content

Instantly share code, notes, and snippets.

@ckob
ckob / asd.sh
Created December 1, 2015 17:37
c=("\e[38;5;9m" "\e[38;5;10m" "\e[38;5;11m" "\e[38;5;13m" "\e[38;5;14m")
while true; do
for((x=0; x < 5; x++)); do
echo -e "${c[x]}"
for((i=0; i < 80; i++ )); do
for((j=0; j < 80; j++ )); do
echo -n "e"
done
echo ""
public static void bubble () {
int[] n = {5, 9, 4, 3, 7, 13, 5, 1};
System.out.println(Arrays.toString(n));
int l = n.length;
int f = l-1;
int tmp = 0;
for (int i=l;i>0;i--) {
for (int x=0;x<f;x++) {
if (n[x] > n[x+1]) {
tmp = n[x];
import java.util.Arrays;
public class bubble {
public static void main (String args[]) {
int[] n = {900, 5, 9, 4, 3, 7, 13, 5, 1, 80, 90, 40, 60, 10, -54, 10, 2, -9090};
System.out.println(Arrays.toString(n));
System.out.println(Arrays.toString(bubble(n)));
}
public static int[] bubble (int n[]) {
int tmp, l = n.length;
@ckob
ckob / Examen Iterativa 10-12-2015.txt
Last active December 15, 2015 12:20
Examen Iterativa 10/12/2015
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(123456789));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(123));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(1234));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(12345));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(1233));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(12334));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(12345561));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(1234556123));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(12));
System.out.println(!conteUnaSerieCapicuaDeLlargadaAlMenys3(1));
@ckob
ckob / solucio dibuix.java
Last active December 16, 2015 22:23
Solucions examen bucles
public static String figuraSensePrint(int n1,int n2){
String s=""; // amb StringBuffer o StringBuilder millor
s="\n\nFigura "+n1+" "+n2+":\n\n";
for (int i=0;i<n1;i++){
s+="@\n";
@ckob
ckob / Program.java
Last active December 16, 2015 22:43
Headers per Geany. /usr/share/geany/templates/files
/*
* Program.java 1.0 {date}
*
* Copyright {year} Charly Koch Busquets <[email protected]>
*
* This is free software, licensed under the GNU General Public License v3.
* See http://www.gnu.org/licenses/gpl.html for more information.
*/
public class Program {
@ckob
ckob / Program.java
Last active December 17, 2015 15:29
Exercici frequent
import java.util.Random;
public class Program {
public static void main (String args[]) {
int[] arr = rndArrInt(100000, -100, 100); // Retorna un array de llargaria 100000 amb nombres aleatoris de -100 a 100
System.out.println(frequent(arr));
}
public static int[] rndArrInt (int llarg, int min, int max) {
Random rand = new Random();
int[] arr = new int[llarg];
@ckob
ckob / Program.java
Created December 17, 2015 15:39
Comparació frequent
import java.util.Random;
public class Program {
public static void main (String args[]) {
int[] arr = rndArrInt(100000, -1000, 1000);
System.out.println("------------------------------");
System.out.println("Solució frequent Alex v1: ");
long startTime = System.nanoTime();
System.out.println(frequentv1(arr));
@ckob
ckob / Program.java
Last active January 11, 2016 20:41
Transpose
import java.util.Arrays;
public class Program {
public static void main (String args[]) {
int[][] o = new int[][]{
{ 1, 20, 10 },
{ 6, 3, 18 }
};
int[][] d = new int[o[0].length][o.length];
@ckob
ckob / Program.java
Last active January 27, 2016 20:01
Creació de la classe Cotxe.java
public class Cotxe {
public static void main (String args[]) {
Cotxe c = new Cotxe("Seat");
c.setVelocitat(150);
System.out.println(c);
}
public final static float MAX_SPEED = 130;
private String marca;