elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


  Mostrar Mensajes
Páginas: 1 2 3 4 5 [6] 7 8
51  Programación / Ejercicios / Re: Ejercicios resueltos C++ [programacion estructurada] en: 1 Marzo 2008, 20:42 pm
Citar
holas me podrias poner problemas de
prosesos secuenciales
if elfe
while
switch

Todo lo que mencionas estan en los ejercicos.
Aunque falta el switch, pero ya lo pondre :)
52  Programación / Ejercicios / Re: Ejercicios resueltos C++ [programacion estructurada] en: 29 Febrero 2008, 19:03 pm
Citar
gracias por los codigos,me serviran para analizarlos

Tengo mas, luego los subire tengo sobre recurisividad, matrices, vectores, archivos, cadenas etc. xD

Que bueno saber que esos ejercicios le sirvio a alguien.
53  Foros Generales / Sugerencias y dudas sobre el Foro / Re: FORO EN INGLES en: 28 Febrero 2008, 18:07 pm
Citar
pues a quien le interese va a aprender español para entrar en este foro

pues tienes razon en esa parte  :)
54  Seguridad Informática / Hacking / Herramientas para burlar a CiberControl en: 26 Febrero 2008, 23:24 pm
En vista de que los enlaces de R.U.B.I.O. ya no van, estan rotos, nisiquiera se muestran las imagenes, aqui posteo los que yo tengo, no son muchos pero SI FUNCIONAN todos, son [100%funcionales]



A veces cuando vamos a un Ciber, muchas veces pasa que:

  *No podemos usar windows+E, windows+r
  *No podemos ejecutar ningun comando
  *Tenemos el volumen muy bajo
  *El maldito de la pc del lado esta usando un programa p2p

Para todo eso tenemos las siguientes herramientas, con las que podremos usar cualquier comando que querramos en windows, podremos mandar un mensaje, colgar, reiniciar, apagar el ordenador a aquel que esta usando un p2p o a aquel que nos caiga mal.Podremos sacar la contaseña de CiberControl,  apagar equipos en masa.

[-] CFR (ciber free) [-]


[-] In-Seguridad_Cyber control [-]


[-] CaCiCo [-]



[-] Ciber puesto hack [-]


[-] CiberKaos [-]


[-] Segurity Zero [-]


[-] Net Send anonimo [-]


55  Programación / Ejercicios / Re: Ejercicios resueltos JAVA [programacion estructurada] en: 26 Febrero 2008, 18:45 pm
>> MATRICES Y VECTORES<<

/*Dada la matrix de m*n y el vector de tamanio n, determinar que columna de la matris
es igual al vector*/

Código:
class JavaMatrisVector2
{
    void llenarMatris (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrarMatris (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void llenarVector (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("Inserte pos.[" + i + "]: ");
    V [i] = Leer.datoInt ();
}
    }


    void mostrarVector (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("[" + V [i] + "]");
}
    }


    void procedure (int M [] [], int f, int c, int V [], int d)
    {
for (int i = 1 ; i <= f ; i++)
{
    int sw = 1;
    for (int j = 1 ; j <= c ; j++)
    {

for (int k = 1 ; k <= d ; k++)
{
    if (M [j] [i] != V [k])
sw = 0;
}
    }
    if (sw == 1)
System.out.println ("\n\nLa columna " + i + " es igual al vector");
}
    }



    public static void main (String args [])
    {
JavaMatrisVector2 h = new JavaMatrisVector2 ();
int M [] [] = new int [20] [20];
int V [] = new int [20];
System.out.print ("Inserte filas de la matris: ");
int f = Leer.datoInt ();
System.out.print ("Inserte dimension del vector: ");
int d = Leer.datoInt ();

System.out.print ("\nLLENANDO MATRIS: \n");
h.llenarMatris (M, f, d);
System.out.print ("\nLLENANDO EL VECTOR: \n");
h.llenarVector (V, d);


System.out.print ("\nLA MATRIS: ");
h.mostrarMatris (M, f, d);
System.out.print ("\n\nEL VECTOR: \n");
h.mostrarVector (V, d);

h.procedure (M, f, d, V, d);
    }
}


/*Dada una matris Z almacenar en un vector A la suma por sus columnas
y en un vector B la suma por sus filas*/

Código:
class JavaMatrisVector3
{
    void llenarMatris (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrarMatris (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void mostrarVector (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("[" + V [i] + "]");
}
    }


    void vectorA (int M [] [], int f, int c, int A [], int d)
    {
for (int i = 1 ; i <= f ; i++)
{
    int suma = 0;
    for (int j = 1 ; j <= c ; j++)
    {
suma = suma + M [j] [i];
    }
    A [i] = suma;
}
    }


    void vectorB (int M [] [], int f, int c, int B [], int d)
    {
for (int i = 1 ; i <= f ; i++)
{
    int suma = 0;
    for (int j = 1 ; j <= c ; j++)
    {
suma = suma + M [i] [j];
    }
    B [i] = suma;
}
    }



    public static void main (String args [])
    {
JavaMatrisVector3 h = new JavaMatrisVector3 ();
int Z [] [] = new int [20] [20];
int A [] = new int [20];
int B [] = new int [20];
System.out.print ("Inserte filas de la matris: ");
int f = Leer.datoInt ();
System.out.print ("Inserte columnas de la matris: ");
int c = Leer.datoInt ();

System.out.print ("\nLLENANDO MATRIS: \n");
h.llenarMatris (Z, f, c);

System.out.print ("\nLA MATRIZ Z: ");
h.mostrarMatris (Z, f, c);

System.out.println ("\n\nSUMA POR COLUMNAS DE LA MATRIS (vector A): ");
h.vectorA (Z, f, c, A, c);
h.mostrarVector (A, c);
System.out.println ("\n\nSUMA POR FILAS DE LA MATRIS (vector B): ");
h.vectorB (Z, f, c, B, f);
h.mostrarVector (B, f);
    }
}
56  Programación / Ejercicios / Re: Ejercicios resueltos C++ [programacion estructurada] en: 26 Febrero 2008, 18:45 pm
>> MATRICES y VECTORES<<

/* Dada una matris y un vector, contar la cantidad de numeros primos de ambos */
Código:
#include <stdio.h>
#include <conio.h>

void llenarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf ("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j] )
  }
 }
}

void llenarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("Inserte pos.[%d]: ",i);
  scanf("%d",&V [i]);
 }
}

void mostrarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("[%d]",V [i]);
 }
}

int primosMatris (int M[20][20], int f, int c)
{
 int cant = 0;
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   int cc = 0;
   for (int k = 1 ; k <= M [i] [j] ; k++)
   {
    if (M [i] [j] % k == 0)
      cc++;
   }
   if (cc == 2)
      cant++;
  }
 }
 return (cant);
}


int primosVector (int V[20], int d)
{
 int cant = 0;
 for (int i = 1 ; i <= d ; i++)
 {
  int c = 0;
  for (int j = 1 ; j <= V [i] ; j++)
  {
   if (V [i] % j == 0)
     c++;
  }
  if (c == 2)
     cant++;
 }
 return (cant);
}



int main()
{
 int M [20] [20];
 int V [20];
 int f, c, d;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte columnas de la matris: ");
 scanf("%d",&c);
 printf ("Inserte dimension del vector: ");
 scanf("%d",&d);

 printf ("\nLLENANDO MATRIS: \n");
 llenarMatris (M, f, c);
 printf ("\nLLENANDO EL VECTOR: \n");
 llenarVector (V, d);

 printf ("\nLA MATRIS: ");
 mostrarMatris (M, f, c);
 printf ("\n\nEL VECTOR: \n");
 mostrarVector (V, d);

 int primos = primosMatris (M, f, c) + primosVector (V, d);
 printf ("\n\nLA CANTIDAD DE NUMEROS PRIMOS QUE HAY EN LOS ARREGLOS ES: %d",primos);
 getch();
}


/*Dada la matrix de m*n y el vector de tamanio n, determinar que columna de la matris
es igual al vector*/

Código:
#include <stdio.h>
#include <conio.h>
   
void llenarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf ("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j] );
  }
 }
}

void llenarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("Inserte pos.[%d]: ",i);
  scanf("%d",&V [i]);
 }
}

void mostrarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("[%d]",V [i]);
 }
}


void procedure (int M[20][20], int f, int c, int V[20], int d)
{
 for (int i = 1 ; i <= f ; i++)
 {
     
  int sw = 1;
  for (int j = 1 ; j <= c ; j++)
  {
   for (int k = 1 ; k <= d ; k++)
   {
    if (M [j] [i] != V [k])
        sw = 0;
   }
  }
  if (sw == 1)
    printf ("\n\nLa columna %d es igual al vector",i);
 }
}



int main ()
{
 int M [20] [20];
 int V [20];
 int f, d;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte dimension del vector: ");
 scanf("%d",&d);

 printf ("\nLLENANDO MATRIS: \n");
 llenarMatris (M, f, d);
 printf ("\nLLENANDO EL VECTOR: \n");
 llenarVector (V, d);


  printf ("\nLA MATRIS: ");
  mostrarMatris (M, f, d);
  printf ("\n\nEL VECTOR: \n");
  mostrarVector (V, d);

  procedure (M, f, d, V, d);
  getch();
}

/*Dada una matris Z almacenar en un vector A la suma por sus columnas
y en un vector B la suma por sus filas  */

Código:
#include <stdio.h>
#include <conio.h>

void llenarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf ("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j] );
  }
 }
}

void llenarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("Inserte pos.[%d]: ",i);
  scanf("%d",&V [i]);
 }
}

void mostrarVector (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("[%d]",V [i]);
 }
}


void vectorA (int M[20][20], int f, int c, int A[20], int d)
{
 for (int i = 1 ; i <= f ; i++)
 {
  int suma = 0;
  for (int j = 1 ; j <= c ; j++)
  {
   suma = suma + M [j] [i];
  }
  A [i] = suma;
 }
}

void vectorB (int M[20][20], int f, int c, int B[20], int d)
{
 for (int i = 1 ; i <= f ; i++)
 {
  int suma = 0;
  for (int j = 1 ; j <= c ; j++)
  {
   suma = suma + M [i] [j];
  }
  B [i] = suma;
 }
}

int main ()
{
 int Z [20] [20];
 int A [20];
 int B [20];
 int f, c;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte columnas de la matris: ");
 scanf("%d",&c);

 printf ("\nLLENANDO MATRIS: \n");
 llenarMatris (Z, f, c);

 printf ("\nLA MATRIZ Z: ");
 mostrarMatris (Z, f, c);

 printf ("\n\nSUMA POR COLUMNAS DE LA MATRIS (vector A): \n");
 vectorA (Z, f, c, A, c);
 mostrarVector (A, c);
 printf ("\n\nSUMA POR FILAS DE LA MATRIS (vector B): \n");
 vectorB (Z, f, c, B, f);
 mostrarVector (B, f);
 getch();
}
57  Programación / Ejercicios / Re: Ejercicios resueltos JAVA [programacion estructurada] en: 26 Febrero 2008, 18:44 pm
>> MATRICES <<

/*Dadas dos matrices A y B intercambiar los minimos de A con los maximos de B*/
Código:
class JavaMatrices1
{
    void llenar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    int menor (int M [] [], int f, int c)
    {
int men = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
if (M [i] [j] < men)
    men = M [i] [j];
    }
}
return (men);
    }


    int maximo (int M [] [], int f, int c)
    {
int max = M [1] [1];
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
if (M [i] [j] < max)
    max = M [i] [j];
    }
}
return (max);
    }



    void intercambiar (int A [] [], int fa, int ca, int B [] [], int fb, int cb)
    {
int min_a = menor (A, fa, ca);
int max_b = maximo (B, fb, cb);

//para cambiar los minimos de A con los maximos de B
for (int i = 1 ; i <= fa ; i++)
{
    for (int j = 1 ; j <= ca ; j++)
    {
if (A [i] [j] == min_a)
    A [i] [j] = max_b;
    }
}

//para intercambiar los maximos de con los minimos de A
for (int i = 1 ; i <= fb ; i++)
{
    for (int j = 1 ; j <= cb ; j++)
    {
if (B [i] [j] == max_b)
    B [i] [j] = min_a;
    }
}
    }


    public static void main (String args [])
    {
JavaMatrices1 h = new JavaMatrices1 ();
int A [] [] = new int [20] [20];
int B [] [] = new int [20] [20];
System.out.print ("Insert filas de A: ");
int fa = Leer.datoInt ();
System.out.print ("Insert columnas de A: ");
int ca = Leer.datoInt ();
System.out.print ("Insert filas de B: ");
int fb = Leer.datoInt ();
System.out.print ("Insert columnas de B: ");
int cb = Leer.datoInt ();

//lectura de matrices
System.out.println ("\nINSERTANDO DATOS EN MATRIS A: \n");
h.llenar (A, fa, ca);
System.out.println ("\nINSERTANDO DATOS EN MATRIS B: \n");
h.llenar (B, fb, cb);
System.out.println ("\nMATRICES ORIGINALMENTE INSERTADAS: ");
h.mostrar (A, fa, ca);
System.out.println ();
h.mostrar (B, fb, cb);
System.out.println ();

//intercambiando elementos
h.intercambiar (A, fa, ca, B, fb, cb);
System.out.println ("\nMATRICES DESPUES DEL INTERCAMBIO:");
h.mostrar (A, fa, ca);
System.out.println ();
h.mostrar (B, fb, cb);
    }
}

/*Dada una matris cuadrada invertir su diagonal principal*/
Código:
class JavaMatrices2
{
    void llenar (int M [] [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    for (int j = 1 ; j <= d ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= d ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void invierte (int M [] [], int d)
    {
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
    int aux = M [i] [i];
    M [i] [i] = M [d] [d];
    M [d] [d] = aux;
    fin--;
}
    }



    public static void main (String args [])
    {
JavaMatrices2 h = new JavaMatrices2 ();
int M [] [] = new int [20] [20];
System.out.print ("Inserte dimen. de la matris cuadrada: ");
int d = Leer.datoInt ();
h.llenar (M, d);
System.out.print ("\nMATRIS ORIGINAL: ");
h.mostrar (M, d);
System.out.print ("\n\nMATRIS CON LA DIAGONAL PRINCIPAL INVERTIDA: ");
h.invierte (M, d);
h.mostrar (M, d);
    }
}


/*Dada una matris cuadrada invertir su diagonal secundaria*/
Código:
class JavaMatrices3
{
    void llenar (int M [] [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    for (int j = 1 ; j <= d ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= d ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void invierte (int M [] [], int d)
    {
int fin = d;
for (int i = 1 ; i <= d / 2 ; i++)
{
    int aux = M [i] [d];
    M [i] [d] = M [d] [i];
    M [d] [i] = aux;
    fin--;
}
    }



    public static void main (String args [])
    {
JavaMatrices3 h = new JavaMatrices3 ();
int M [] [] = new int [20] [20];
System.out.print ("Inserte dimen. de la matris cuadrada: ");
int d = Leer.datoInt ();
h.llenar (M, d);
System.out.print ("\nMATRIS ORIGINAL: ");
h.mostrar (M, d);
System.out.print ("\n\nMATRIS CON LA DIAGONAL SECUNDARIA INVERTIDA: ");
h.invierte (M, d);
h.mostrar (M, d);
    }
}


/*Dada dos matrices de diferentes tamanios R y S mostrar los elementos comunes de R en S*/
Código:
class JavaMatrices4
{
    void llenar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void comunes (int R [] [], int fr, int cr, int S [] [], int fs, int cs)
    {
System.out.print ("\n\nLos elementos comunes de R en S son: ");
for (int i = 1 ; i <= fr ; i++)
{
    for (int j = 1 ; j <= cr ; j++)
    {
for (int k = 1 ; k <= fs ; k++)
{
    for (int l = 1 ; l <= cs ; l++)
    {
if (R [i] [j] == S [k] [l])
    System.out.print ("[" + R [i] [j] + "]");
    }
}
    }
}
    }



    public static void main (String args [])
    {
JavaMatrices4 h = new JavaMatrices4 ();
int R [] [] = new int [20] [20];
int S [] [] = new int [20] [20];
System.out.print ("Inserte filas de R: ");
int fr = Leer.datoInt ();
System.out.print ("Inserte columnas de R: ");
int cr = Leer.datoInt ();
System.out.print ("Inserte filas de S: ");
int fs = Leer.datoInt ();
System.out.print ("Inserte columnas de S: ");
int cs = Leer.datoInt ();

System.out.print ("\nLLENANDO MATRIS R: \n");
h.llenar (R, fr, cr);
System.out.print ("\nLLENANDO MATRIS S: \n");
h.llenar (S, fs, cs);
System.out.print ("\nLA MATRICES R : ");
h.mostrar (R, fr, cr);
System.out.print ("\nLA MATRICES S : ");
h.mostrar (S, fs, cs);
h.comunes (R, fr, cr, S, fs, cs);
    }
}


/*Dada una matris intercambiar los elementos de la primera columna con la ultima columna*/
Código:
class JavaMatrices5
{
    void llenar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}
    }


    void intercambiar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    int aux = M [i] [1];
    M [i] [1] = M [i] [c];
    M [i] [c] = aux;
}
    }


    public static void main (String args [])
    {
JavaMatrices5 h = new JavaMatrices5 ();
int M [] [] = new int [20] [20];
System.out.print ("Inserte filas de la matris: ");
int f = Leer.datoInt ();
System.out.print ("Inserte columnas de la matris: ");
int c = Leer.datoInt ();

System.out.print ("\nLLENANDO MATRIS : \n");
h.llenar (M, f, c);
System.out.print ("\nLA MATRIS ORIGINAL : ");
h.mostrar (M, f, c);
System.out.print ("\n\nLA MATRICES INTERCAMBIADA : ");
h.intercambiar (M, f, c);
h.mostrar (M, f, c);
    }
}

/* Contar el numero de digitos de cada elemento de una matris */
Código:
class JavaMatrices6
{
    void llenar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("Inserte pos[" + i + "][" + j + "]: ");
M [i] [j] = Leer.datoInt ();
    }
}
    }


    void mostrar (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    System.out.println ();
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("[" + M [i] [j] + "]");
    }
}

    }


    void cuenta (int M [] [], int f, int c)
    {
for (int i = 1 ; i <= f ; i++)
{
    for (int j = 1 ; j <= c ; j++)
    {
System.out.print ("\n[" + M [i] [j] + "] tiene: " + digitos (M [i] [j]) + " digito(s)");
    }
}
    }


    int digitos (int n)
    {
int contador = 0;
while (n != 0)
{
    n = n / 10;
    contador++;
}
return (contador);
    }


    public static void main (String args [])
    {
JavaMatrices6 h = new JavaMatrices6 ();
int M [] [] = new int [20] [20];
System.out.print ("Inserte filas de la matris: ");
int f = Leer.datoInt ();
System.out.print ("Inserte columnas de la matris: ");
int c = Leer.datoInt ();

System.out.print ("\nLLENANDO MATRIS M: \n");
h.llenar (M, f, c);
System.out.print ("\nLA MATRIS: ");
h.mostrar (M, f, c);
System.out.print ("\n\nCONTEO DE DIGITOS: ");
h.cuenta (M, f, c);
    }
}
58  Programación / Ejercicios / Re: Ejercicios resueltos C++ [programacion estructurada] en: 26 Febrero 2008, 18:44 pm
>> MATRICES <<

Generar la matriz:
    [01][02][03][04]
    [08][07][06][05]
    [09][10][11][12]
Código:
#include<stdio.h>
#include<conio.h>
void llenar (int M[20][20], int f, int c)
{
     int k=1;
     for (int i=1;i<=f;i++)
     {
         if (i%2!=0)
         {
            for (int j=1;j<=c;j++)
            {
               M[i][j]=k; k++;
            }
         }
         else
         {
            for (int j=c;j>=1;j--)
            {
               M[i][j]=k; k++;
            }
         }
     }
}

void mostrar (int M[20][20], int f, int c)
{
  for (int i=1;i<=f;i++)
  {
    printf("\n"); 
    for (int j=1;j<=c;j++)
    {
       printf("[%d] ",M[i][j]);
    }
  }
}

int main ()
{
    int f, c;
    int M[20][20];
    printf("Inserte filas de M: "); scanf("%d",&f);
    printf("Inserte cols. de M: "); scanf("%d",&c);
    llenar(M, f, c);
    mostrar(M, f, c);
    getch();
}


Generar la matriz:
    [01][02][03][04]
    [05][06][07][00]
    [08][09][00][00]
    [10][00][00][00]
Código:
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
     int cont=1;
     for (int i=1;i<=d;i++)
     {
         for (int j=1;j<=d;j++)
         {
             if ((i+j)<=(d+1))
             {M[i][j]=cont; cont++;}
             else
             M[i][j]=0;
         }
     }
}

void mostrar (int M[20][20], int d)
{
     for (int i=1;i<=d;i++)
     {
         printf("\n");
         for (int j=1;j<=d;j++)
         {
            printf ("[%d] ",M[i][j]);
         }
     }
}

int main ()
{
    int d;
    int M[20][20];
    printf("Insert dimen: "); scanf("%d",&d);
    llenar(M, d);
    mostrar(M, d);
    getch();
}

Dadas dos matrices A y B intercambiar los minimos de A con los maximos de B
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M[i][j]);
  }
 }
}
 
void mostrar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M[i][j]);
  }
 }
}

int menor (int M[20][20], int f, int c)
{
 int men = M [1] [1];
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   if (M [i] [j] < men)
      men = M [i] [j];
  }
 }
 return (men);
}
 
int maximo (int M[20][20], int f, int c)
{
 int max = M [1] [1];
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   if (M [i] [j] > max)
      max = M [i] [j];
  }
 }
 return (max);
}

void intercambiar (int A[20][20], int fa, int ca, int B[20][20], int fb, int cb)
{
 int min_a = menor (A, fa, ca);
 int max_b = maximo (B, fb, cb);
 //para cambiar los minimos de A con los maximos de B
 for (int i = 1 ; i <= fa ; i++)
 {
  for (int j = 1 ; j <= ca ; j++)
  {
   if (A[i][j] == min_a)
     A[i][j]=max_b;
  }
 }
 //para intercambiar los maximos de con los minimos de A
 for (int i = 1 ; i <= fb ; i++)
 {
  for (int j = 1 ; j <= cb ; j++)
  {
   if (B[i][j] == max_b)
     B[i][j]=min_a;
  }
 }
}

int main ()
{
 int A [20] [20];
 int B [20] [20];
 int fa, ca, fb, cb;
 printf ("Insert filas de A: "); scanf("%d",&fa);
 printf ("Insert columnas de A: "); scanf("%d",&ca);
 printf ("Insert filas de B: "); scanf("%d",&fb);
 printf ("Insert columnas de B: "); scanf("%d",&cb);
 
 //lectura de matrices
 printf ("\nINSERTANDO DATOS EN MATRIS A: \n");
 llenar (A, fa, ca);
 printf ("\nINSERTANDO DATOS EN MATRIS B: \n");
 llenar (B, fb, cb);
 printf ("\nMATRICES ORIGINALMENTE INSERTADAS: ");
 mostrar (A, fa, ca);
 printf ("\n");
 mostrar (B, fb, cb);
 printf ("\n");
 //intercambiando elementos
 intercambiar (A, fa, ca, B, fb, cb);
 printf ("\nMATRICES DESPUES DEL INTERCAMBIO:");
 mostrar (A, fa, ca);
 printf ("\n");
 mostrar (B, fb, cb);
 getch();
}


/*Dada una matris cuadrada invertir su diagonal principal*/
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int M[20][20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  for (int j = 1 ; j <= d ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i, j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrar (int M[20][20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= d ; j++)
  {
   printf ("[%d]",M [i] [j]);
  }
 }
}

void invierte (int M[20][20], int d)
{
 int fin = d;
 for (int i = 1 ; i <= d / 2 ; i++)
 {
  int aux = M [i] [i];
  M [i] [i] = M [d] [d];
  M [d] [d] = aux;
  fin--;
 }
}

int main()
{
 int M [20] [20];
 int d;
 printf ("Inserte dimen. de la matris cuadrada: ");
 scanf("%d",&d);
 llenar (M, d);
 printf ("\nMATRIS ORIGINAL: ");
 mostrar (M, d);
 printf ("\n\nMATRIS CON LA DIAGONAL PRINCIPAL INVERTIDA: ");
 invierte (M, d);
 mostrar (M, d);
 getch();
}

/*Dada una matris cuadrada invertir su diagonal secundaria*/
Código:
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  for (int j = 1 ; j <= d ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i, j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrar (int M[20][20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= d ; j++)
  {
   printf ("[%d]",M [i] [j]);
  }
 }
}

void invierte (int M[20][20], int d)
{
 int fin = d;
 for (int i = 1 ; i <= d / 2 ; i++)
 {
  int aux = M [i] [d];
  M [i] [d] = M [d] [i];
  M [d] [i] = aux;
  fin--;
 }
}

int main()
{
 int M [20] [20];
 int d;
 printf ("Inserte dimen. de la matris cuadrada: ");
 scanf("%d",&d);
 llenar (M, d);
 printf ("\nMATRIS ORIGINAL: ");
 mostrar (M, d);
 printf ("\n\nMATRIS CON LA DIAGONAL SECUNDARIA INVERTIDA: ");
 invierte (M, d);
 mostrar (M, d);
 getch();
}

/*Dada dos matrices de diferentes tamanios R y S mostrar los elementos comunes de R en S*/
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j]);
  }
 }
}

void comunes (int R[20][20], int fr, int cr, int S[20][20], int fs, int cs)
{
 printf("\n\nLos elementos comunes de R en S son: ");
 for (int i = 1 ; i <= fr ; i++)
 {
  for (int j = 1 ; j <= cr ; j++)
  {
   for (int k = 1 ; k <= fs ; k++)
   {
    for (int l = 1 ; l <= cs ; l++)
    {
     if (R [i] [j] == S [k] [l])
       printf ("[%d]",R [i] [j]);
    }
   }
  }
 }
}

int main()
{
 int R [20] [20];
 int S [20] [20];
 int fr, cr, fs, cs;
 printf("Inserte filas de R: ");
 scanf("%d",&fr);
 printf("Inserte columnas de R: ");
 scanf("%d",&cr);
 printf("Inserte filas de S: ");
 scanf("%d",&fs);
 printf("Inserte columnas de S: ");
 scanf("%d",&cs);
 
 printf("\nLLENANDO MATRIS R: \n");
 llenar (R, fr, cr);
 printf("\nLLENANDO MATRIS S: \n");
 llenar (S, fs, cs);
 printf("\nLA MATRIS R : ");
 mostrar (R, fr, cr);
 printf("\n\nLA MATRIS S : ");
 mostrar (S, fs, cs);
 comunes (R, fr, cr, S, fs, cs);
 getch();
}


/*Intercambiar los datos de la columna 1 con la ultima columna*/
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos:[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j]);
  }
 }
}

void intercambiar (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  int aux = M [i] [1];
  M [i] [1] = M [i] [c];
  M [i] [c] = aux;
 }
}

int main ()
{
 int M [20] [20];
 int f, c;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte columnas de la matris: ");
 scanf("%d",&c);

 printf ("\nLLENANDO MATRIS : \n");
 llenar (M, f, c);
 printf ("\nLA MATRIS ORIGINAL : ");
 mostrar (M, f, c);
 printf ("\n\nLA MATRICES INTERCAMBIADA : ");
 intercambiar (M, f, c);
 mostrar (M, f, c);
 getch();
}


/* Contar el numero de digitos de cada elemento de una matris */
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int M [20] [20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrar (int M [20] [20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j]);
  }
 }
}

void cuenta (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   int contador = 0;
   int n=M[i][j];
   while (n != 0)
    {
     n = n / 10;
     contador++;
    }
    printf("\n[%d] tiene: %d digito(s)",M[i][j],contador);
  }
 }
}

int main ()
{
 int M [20] [20];
 int f, c;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte columnas de la matris: ");
 scanf("%d",&c);

 printf ("\nLLENANDO MATRIS M: \n");
 llenar (M, f, c);
 printf ("\nLA MATRIS: ");
 mostrar (M, f, c);
 printf ("\n\nCONTEO DE DIGITOS: ");
 cuenta (M, f, c);
 getch();
}


/*Hallar la fila y la columna del primer elemento "e" */
Código:
#include <stdio.h>
#include <conio.h>

void llenarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("Inserte pos[%d][%d]: ",i,j);
   scanf("%d",&M [i] [j]);
  }
 }
}

void mostrarMatris (int M[20][20], int f, int c)
{
 for (int i = 1 ; i <= f ; i++)
 {
  printf ("\n");
  for (int j = 1 ; j <= c ; j++)
  {
   printf ("[%d]",M [i] [j] );
  }
 }
}

void busqueda (int M[20][20], int f, int c, int e)
{
 int bn = 0;
 for (int i = 1 ; i <= f ; i++)
 {
  for (int j = 1 ; j <= c ; j++)
  {
   if (M [i] [j] == e)
   {
    printf("\nEl numero: %d se encuentra en la posicion: [%d][%d] de la matris",e, i, j);
    bn = 1;
   }
  }
 }
 if (bn == 0)
  printf("\nNo se encontro el numero %d en la matris :(",e);
}

int main ()
{
 int M [20] [20];
 int f, c, numero;
 printf ("Inserte filas de la matris: ");
 scanf("%d",&f);
 printf ("Inserte columnas de la matris: ");
 scanf("%d",&c);

 printf ("\nLLENANDO MATRIS: \n");
 llenarMatris (M, f, c);
 printf ("\nLA MATRIZ Z: ");
 mostrarMatris (M, f, c);

 printf ("\n\nInserte un numero: ");
 scanf("%d",&numero);
 busqueda (M, f, c, numero);
 getch();
}
59  Programación / Ejercicios / Re: Ejercicios resueltos JAVA [programacion estructurada] en: 26 Febrero 2008, 18:43 pm
>> VECTORES <<

/*Dado el vector T de tamao n. Si el tamao es par invertir los elementos de la mitad de los elementos
Ejemplo:   v=[1][2][3][4][5][6]      v(invertido)=[3][2][1][6][5][4]
*/

Código:
class JavaVectores1
{
    void llenar (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("Inserte pos.[" + i + "]: ");
    V [i] = Leer.datoInt ();
}
    }


    void mostrar (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("[" + V [i] + "]");
}
    }


    void invierte (int V [], int d)
    {
int aux1;
int fin1 = d / 2;
for (int i = 1 ; i <= (d / 2) / 2 ; i++)
{
    aux1 = V [i];
    V [i] = V [fin1];
    V [fin1] = aux1;
    fin1--;
}

fin1 = d;
for (int j = (d / 2) + 1 ; j <= (d / 2) + 1 ; j++)
{
    aux1 = V [j];
    V [j] = V [fin1];
    V [fin1] = aux1;
    fin1--;
}
    }


    public static void main (String args [])
    {
JavaVectores1 h = new JavaVectores1 ();
int V [] = new int [20];
System.out.print ("Inserte dimen. del vector: ");
int d = Leer.datoInt ();
h.llenar (V, d);
System.out.println ("\nVECTOR ORIGINAL: ");
h.mostrar (V, d);
System.out.println ("\nVECTOR LUEGO DE LA INVERSION: ");
h.invierte (V, d);
h.mostrar (V, d);
    }
}

/*Dado un polinomio evualuarlo en el punto x (todo en un vector)*/
Código:
class JavaVectores2
{
    void llenar (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("Inserte pos.[" + i + "]: ");
    V [i] = Leer.datoInt ();
}
    }


    void mostrar (int V [], int d)
    {
for (int i = 1 ; i <= d ; i++)
{
    System.out.print ("[" + V [i] + "]");
}
    }


    int potencia (int b, int e)
    {
int p = 1;
for (int i = 1 ; i <= e ; i++)
{
    p = p * b;
}
return (p);
    }


    void evalua (int V [], int d, int x)
    {
int s = 0;
for (int i = 1 ; i <= d ; i += 2)
{
    s = s + (V [i] * potencia (x, V [i + 1]));
}
System.out.println ("\n\nX es igual a: " + s);
    }


    public static void main (String args [])
    {
JavaVectores2 h = new JavaVectores2 ();
int V [] = new int [20];
System.out.print ("Inserte dimen. del vector: ");
int d = Leer.datoInt ();
System.out.print ("Inserte valor de (x): ");
int x = Leer.datoInt ();
h.llenar (V, d);
System.out.println ("\nVECTOR: ");
h.mostrar (V, d);
h.evalua (V, d, x);
    }
}
60  Programación / Ejercicios / Re: Ejercicios resueltos C++ [programacion estructurada] en: 26 Febrero 2008, 18:42 pm
>> VECTORES <<

/*Dado el vector T de tamao n. Si el tamao es par invertir los elementos de la mitad de los elementos
Ejemplo:   v=[1][2][3][4][5][6]      v(invertido)=[3][2][1][6][5][4]
*/

Código:
#include<stdio.h>
#include<conio.h>

void llenar (int V [], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("Inserte pos.[%d]: ",i);
  scanf("%d",&V[i]);
 }
}

void mostrar (int V [], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("[%d]",V[i]);
 }
}

void invierte (int V [], int d)
{
 int aux1;
 int fin1 = d / 2;
 for (int i = 1 ; i <= (d / 2) / 2 ; i++)
 {
  aux1 = V [i];
  V [i] = V [fin1];
  V [fin1] = aux1;
  fin1--;
 }

 fin1 = d;
 for (int j = (d / 2) + 1 ; j <= (d / 2) + 1 ; j++)
 {
  aux1 = V [j];
  V [j] = V [fin1];
  V [fin1] = aux1;
  fin1--;
 }
}

int main ()
{
 int V[20];
 int d;
 printf ("Inserte dimen. del vector: "); scanf("%d",&d);
 llenar (V, d);
 printf ("\nVECTOR ORIGINAL: \n");
 mostrar (V, d);
 printf ("\n\nVECTOR LUEGO DE LA INVERSION: \n");
 invierte (V, d);
 mostrar (V, d);
 getch();
}

/*Dado un polinomio evualuarlo en el punto x (todo en un vector)*/
Código:
#include <stdio.h>
#include <conio.h>

void llenar (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("Inserte pos.[%d]: ",i);
  scanf("%d",&V[i]);
 }
}

void mostrar (int V[20], int d)
{
 for (int i = 1 ; i <= d ; i++)
 {
  printf ("[%d]",V[i]);
 }
}

int potencia (int b, int e)
{
 int p = 1;
 for (int i = 1 ; i <= e ; i++)
 {
  p = p * b;
 }
 return (p);
}

void evalua (int V [], int d, int x)
{
 int s = 0;
 for (int i = 1 ; i <= d ; i += 2)
 {
  s = s + (V [i] * potencia (x, V [i + 1]));
 }
 printf("\n\nX es igual a: %d",s);
}

int main ()
{
 int V[20];
 int d, x;
 printf("Inserte dimen. del vector: ");
 scanf("%d",&d);
 printf ("Inserte valor de (x): ");
 scanf("%d",&x);
 llenar (V, d);
 printf("\nVECTOR: ");
 mostrar (V, d);
 evalua (V, d, x);
 getch();
}
Páginas: 1 2 3 4 5 [6] 7 8
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines