Anda di halaman 1dari 11

Programas xD

package funcionesdecadena;

public class Funcionesdecadena {

static String Trim(String s) {

String k="";

int i=0;

while (s.charAt(i++)!=' ') {

int e=0;

while (s.charAt(--e)!=' ') {

for (int j = i; j <= e; j++) {

k+=s.charAt (j);

return k;

public static void main(String[] args) {

// String s="hola";

// System.out.println(s.length());

//

// System.out.println(s.concat("mundo"));
//

// s=s.concat ("mundo");

// System.out.println(s);

// //si escribo s. trim ()

// //quita los espacions en blanco

//

//

// String k=s.substring(3,9);

// System.out.println(k);

//

// for (int i=0;i < s.length();i++){

// }

// String q= Trim (" Hola " );

// System.out.println(q);

System.out.println((char)'A'+32);

}
package nuevotema2;

// @author Diegoandres

//Funciones recursivas

public class Nuevotema2 {

static void llenar (int vector[],int w){

if (w!=vector.length){

vector[w]=w+1;

llenar(vector , w+1);

static void imprimir (int vector[],int w){

if (w!=vector.length){

System.out.println(vector[w]+"");

imprimir (vector ,w++);

static void buscarnum (int vector[],int n, int i){

if (vector[i]==n ){

System.out.println("la pocision del numero es "+i);

}else{
buscarnum(vector, n, i+1);

public static void main(String[] args) {

int [] vector ={1,2,3,4,5,6,7,8,9};

// long q= factorial (5);

// System.out.println(""+q);

// printR(5,50);

buscarnum(vector,5,0);

static long factorial (int x){

if(x==1){

return 1;

return x*factorial(x-1);

static void printR (int x, int y){

if (x!=y){

System.out.println(++x);

printR(x,y);

}
********************************************************
package nuevo.tema;

import java.util.ArrayList;

/**

* @author Diegoandres

*/

public class NuevoTema {

/**

* @param args the command line arguments

*/

static String concatVector (int [] q){

String s="";

for (int i = 0; i < q.length ; i++) {

s+= q[i]+"";

return s;

public static void main(String[] args) {

// TODO code application logic here

//

//////separar numero spares e impares de un arreglo

int c=1;
int vector []= new int [10];

for (int i = 0; i <vector.length; i++) {

vector[i]=c++;

for (int i = 0; i <vector.length; i++) {

if(vector[i]%2==0){

System.out.println("el numero en la posicion "+i+" es par y es el numero "+vector[i]);

System.out.println("\n");

System.out.println("\n");

System.out.println("\n");

for (int i = 0; i <vector.length; i++) {

if(vector[i]%2!=0){

System.out.println("el numero en la posicion "+i+" es impar y es el numero "+vector[i]);

System.out.println("\n");

System.out.println("\n");

System.out.println("\n");

int mayor=vector[0];

int z=0;

for (int i = 0; i <vector.length; i++) {


if (mayor<vector[i]){

mayor=vector[i];

System.out.println("el numero mayor del vector es "+mayor);

System.out.print("\n");

for (int j = 0; j < vector.length; j++) {

int x=0;

for (int i = 1; i <=vector[j]; i++) {

if(vector[j]%i==0){

x++;

if(x==2){

System.out.println("este numero es primo "+vector [j]);

// ArrayList<int []> lista =new ArrayList<>();

//

// int []a={1,2,3,4,5,6};

// lista.add(a);

// lista.add(a);

// lista.add(a);

// lista.add(a);
//

// for (int []elemento: lista)

// {

// System.out.println(elemento[2]);

//// System.out.println (concatVector(elemento));

// }

}
****************************************************************+

package javaapplication14;

/**

* @author Diegoandres

*/

public class JavaApplication14 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.println("Dijite dimencion de la matriz");

int num1=new java.util.Scanner (System.in).nextInt();

int num2=new java.util.Scanner (System.in).nextInt();

int a[][]=new int[num1][num2];

for (int i = 0; i < a .length; i++) {

for (int j = 0; j < a[0].length ; j++) {

System.out.println("dijite numero en la posicion "+ i +","+ j);

a[i][j]= new java.util.Scanner (System.in).nextInt();

for (int i = 0; i < a .length; i++) {

System.out.println(" ");

System.out.println(" ");

if(i==0){

System.out.println("esta es la matriz que usted digito");


System.out.println("-----------------------------------------");

System.out.println(" ");

for (int j = 0; j < a[0].length ; j++) {

System.out.print(a[i][j]+" ");

System.out.println("\n");

System.out.println("Dijite el numero que desea conocer sus \n coordenadas dentro de la


matriz");

System.out.println("-----------------------------------------------------------------------");

int x= new java.util.Scanner (System.in).nextInt();

for (int i = 0; i < a .length; i++) {

for (int j = 0; j < a[0].length ; j++) {

if(x==a[i][j]){

System.out.println("el numero "+x+" esta en la posicion "+i+","+j);

System.out.println("");

System.out.println("");

System.out.println("");

System.out.println("***********************************");

System.out.println("* la fila contiene estos numeros *");

System.out.println("***********************************");

for (int q = 0; q <a.length; q++) {

System.out.print (a[i][q]+" ");

System.out.println("");
System.out.println("");

System.out.println("");

System.out.println("****************************************");

System.out.println("* la columana contiene estos numeros *");

System.out.println("****************************************");

for (int q = 0; q < a.length; q++) {

System.out.println (a[q][j]);