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

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 [2] 3
11  Programación / Java / una duda con colecciones en: 26 Mayo 2010, 22:13 pm
hola amigos
tengo una duda
este programa no es mio pero la duda mas que todo radica en el for del metodo publico mostrar
en esta linea
Código:
 public static void mostrar(ArrayList <alumno> registro){
        for(alumno rocker:registro){ rocker.mostrar();}

    }
bueno aqui esta todo el codigo para que no hayga confusiones
Código:
/**
 * Resolucion del examen 2 - fase
 * @author Figo
 */
import java.util.ArrayList;

class alumno{
    String codigo,nombre;
    int nota1,nota2,nota3;
    public void get_name(String name){ nombre=name; }
    public void get_codigo(String code){ codigo=code; }
    public void get_notas(int n1,int n2,int n3){ nota1=n1; nota2=n2; nota3=n3; }
    public void mostrar(){
        System.out.println("+--------------------------------------+");
        System.out.println("| Nombre: "+nombre);
        System.out.println("| Codigo: "+codigo);
        System.out.println("| promedio: "+(nota1+nota2+nota3)/3);
        System.out.println("----------------------------------------");
    }

}
public class examen {
    public static void main(String args[]){
        ArrayList <alumno> registro=new ArrayList <alumno>();
        alumno a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
        a1=new alumno();
        a2=new alumno();
        a3=new alumno();
        a4=new alumno();
        a5=new alumno();
        a6=new alumno();
        a7=new alumno();
        a8=new alumno();
        a9=new alumno();
        a10=new alumno();
        //****************************************************
        a1.get_name("Oscar");
        a1.get_codigo("2009607113");
        a1.get_notas(17, 20, 20);
        //****************************************************
        a2.get_name("Maricielo");
        a2.get_codigo("2009607114");
        a2.get_notas(15, 10, 20);
        //****************************************************
        a3.get_name("Jesus");
        a3.get_codigo("2009607128");
        a3.get_notas(11, 12, 12);
        //****************************************************
        a4.get_name("Carlos");
        a4.get_codigo("2009607110");
        a4.get_notas(15, 20, 18);
        //****************************************************
        a5.get_name("Chipana");
        a5.get_codigo("200960007");
        a5.get_notas(20, 20, 20);
        //****************************************************
        a6.get_name("Muñeca");
        a6.get_codigo("2009607112");
        a6.get_notas(8, 10, 17);
        //****************************************************
        a7.get_name("Jean claude");
        a7.get_codigo("2009607111");
        a7.get_notas(7, 30, 10);
        //****************************************************
        a8.get_name("Rivas");
        a8.get_codigo("2009607122");
        a8.get_notas(17, 13, 15);
        //****************************************************
        a9.get_name("Jesus");
        a9.get_codigo("2009607107");
        a9.get_notas(17, 20, 20);
        //****************************************************
        a10.get_name("Crispin");
        a10.get_codigo("200967178");
        a10.get_notas(17, 20, 20);
        //***************************************************
        registro.add(a1);
        registro.add(a2);
        registro.add(a3);
        registro.add(a4);
        registro.add(a5);
        registro.add(a6);
        registro.add(a7);
        registro.add(a8);
        registro.add(a9);
        registro.add(a10);
        mostrar(registro);
    }
    public static void mostrar(ArrayList <alumno> registro){
        for(alumno oscar:registro){ oscar.mostrar();}

    }

}


salu...
12  Programación / Programación C/C++ / Re: Algunos Sources basicos en: 24 Mayo 2010, 00:01 am
lo siento amigos es que me acostumbre a escribir asi
y no me di cuenta ya modifique para que sea mas entendible
gracias...
tan wenos los sources :D
salu..
13  Programación / Programación C/C++ / Re: Algunos Sources basicos en: 23 Mayo 2010, 03:58 am
weno mis codigos estan bien hechos no veo la manera de krear discusiones de algo que esta bien
todos ejecutan
ademas seria mucho trabajo leer todos mejor
seria que los guarden como estan
weno ese es mi parecer
weno lo ire arreglando
posteando muxos codigos mas sobre otros temas
...
salu...
14  Programación / Programación C/C++ / Algunos Sources basicos en: 23 Mayo 2010, 03:02 am
hola a todos los miembros del foro
bueno la otra ves dije que iba a postear algunos sources basicos para los  que recien estan aprendiendo c++
yo uso el compilador del visual c++ 6.0
bueno en ese tiempo usaba ese ahora uso el 2008
estan bien aunque no son muchos pero son basicos sin mas que decir hay los dejo
http://depositfiles.com/es/files/qpbxwli94
http://depositfiles.com/es/files/7z71gzjzi
son dos archivos
Salu espero que les sirva... :D
15  Programación / Programación C/C++ / Re: hola ayudenme porfavor en: 17 Mayo 2010, 01:28 am
mm yo te ayudaria pero se c++
weno mirando tu programa x no tiene valor inicial tal ves ese sea el problema
pero mejor
as tu prueba de escritorio
as un seguimiento de tu programa en papel
y veras el error mas claramente :d
salu....
16  Programación / Programación C/C++ / AYUDA error maldito en: 17 Mayo 2010, 01:17 am
olaz manes weno quiero que me ayuden con este programa no se que esta mal pero me sale identificador no declararo y esta declarado :D hay les dejo el codigo esta en dos partes .h y .cpp
AKI EL PUNTO CPP
Código:
//Programa para probar varias opciones de una Pila

#include "iostream"
#include "myStackLinked.h"
#include "stdio.h"
using namespace std;

void main()
{
    int valor;
   
stackType<int> intStack;
stackType<int> tempStack;
    intStack.initializeStack();
cout<<"Usted ha creado una pila de 5 posiciones";
cout<< endl;
intStack.push(23);
intStack.push(45);
intStack.push(38);

tempStack = intStack;  //copia intStack en copyStack

cout<<"Elementos en la pila tempStack: ";
cout<<endl;
   

while(!tempStack.isEmptyStack())  //print copyStack
{
cout<<tempStack.top()<<" ";
    tempStack.pop();
}

cout<<endl;
cout<< "Ingrese un nuevo elemento para la pila: ";
    cin>>valor;
intStack.push(valor);

cout<< "Ingrese un nuevo elemento para la pila: ";
    cin>>valor;
intStack.push(valor);

// Mostrando la pila
    while(!intStack.isEmptyStack())  //print intStack
{
cout<<intStack.top()<<" ";
    intStack.pop();
}

    cout<<endl;
    cout<< "Ingrese un nuevo elemento para la pila: ";
    cin>>valor;
intStack.push(valor);

    cout<<endl;
cout<< "Ingrese un nuevo elemento para la pila: ";
    cin>>valor;
intStack.push(valor);

cout<<endl;
cout<<"El elemnto en el tope de  intStack es: "<<intStack.top()<<endl;


//cout<<"Ahora el elemnto en el tope de  intStack es: "<<intStack.top()<<endl;
//cout<<tempStack.top()<<" ";

system("pause");

}






AKI EL .H


Código:
// myStackLinked.h; Header file

#ifndef H_StackType
#define H_StackType

#include <iostream>
#include <cassert>

using namespace std;

template <class Type>
struct nodeType
{
Type info;
nodeType<Type> *stackTop;
};

template<class Type>
class stackType
{
public:
    const stackType<Type>& operator=(const stackType<Type>&);

    void initializeStack();
//Function to initialize the stack to an empty state.
//Postcondition: stackTop = 0
void destroyStack();
//Function to remove all the elements from the stack.
//Postcondition: stackTop = 0
    bool isEmptyStack();
//Function to determine whether the stack is empty.
//Postcondition: Returns true if the stack is empty;
//               otherwise, returns false.
    void push(const Type& newItem);
//Function to add newItem to the stack.
//Precondition: The stack exists and is not full.
//Postcondition: The stack is changed and newItem
//               is added to the top of stack.
    Type top();
//Function to return the top element of the stack.
//Precondition: The stack exists and is not empty.
  //Postcondition: If the stack is empty, the program
//               terminates; otherwise, the top element
//               of the stack is returned.
    void pop();
//Function to remove the top element of the stack.
//Precondition: The stack exists and is not empty.
//Postcondition: The stack is changed and the top
//               element is removed from the stack.

    stackType();
//constructor
//Creates an array of the size stackSize to hold the
//stack elements. The default stack size is 100.
//Postcondition: The variable list contains the base
//               address of the array, stackTop = 0, and 
//               maxStackSize = stackSize.
    stackType(const stackType<Type>& otherStack);
//copy constructor
    ~stackType();
//destructor
//Removes all the elements from the stack.
//Postcondition: The array (list) holding the stack
//               elements is deleted.

private:

    nodeType<Type> *link;
    void copyStack(const stackType<Type>& otherStack);
  //Function to make a copy of otherStack.
  //Postcondition: A copy of otherStack is created and
  //               assigned to this stack.
};


template<class Type>
void stackType<Type>::initializeStack()
{
destroyStack();
}

template<class Type>
void stackType<Type>::destroyStack()
{
nodeType<Type> *temp;

while(stackTop != NULL)
{
   temp = stackTop;
   stackTop = stackTop->link;
   delete temp;
}

stackTop = 0;
}
template<class Type>
bool stackType<Type>::isEmptyStack()
{
return (stackTop==0);
}

template<class Type>
void stackType<Type>::push(const Type& newItem)
{
nodeType<Type> *newNode;

newNode = new nodeType<Type>;

assert(newNode != NULL);

newNode->info = newItem;
newNode->stackTop = stackTop;
  stackTop = newNode;
                                                             
}

template<class Type>
Type stackType<Type>::top()
{
assert(stackTop!= 0);
return (stackTop->info);
}

template<class Type>
void stackType<Type>::pop()
{
nodeType<Type> *temp;
if(!isEmptyStack()){
   temp=stackTop;
   stackTop=stackTop->link;     
   delete temp;
}
  else
   cerr<<"Cannot remove from an empty stack."<<endl;
}

template<class Type>
stackType<Type>::stackType()
{
stackTop = 0;
}

template<class Type>
stackType<Type>::~stackType() //destructor
{
   destroyStack();
}

template<class Type>
void stackType<Type>::copyStack(const stackType<Type>& otherStack)
{

   nodeType<Type> *newNode;
   nodeType<Type> *current;

   if(!isEmptyStack())
  destroyList();

   if(otherList.isEmptyStack())
stackTop = NULL;
   else
   {
current = otherList.stackTop;

stackTop = new nodeType<Type>;

  assert(stackTop != NULL);

stackTop->info = current->info;
stackTop->link = NULL;

current = current->link;

while(current != NULL)
{
newNode = new nodeType<Type>;

assert(newNode!= NULL);

newNode->info = current->info;
newNode->link = NULL;   
                                   
current = current->link;
}
}
}


template<class Type>
stackType<Type>::stackType(const stackType<Type>& otherStack)
{
stackTop = NULL;

copyStack(otherStack);
}

template<class Type>
const stackType<Type>& stackType<Type>::operator=
    (const stackType<Type>& otherStack)
{

   if(this != &otherStack)
    copyStack(otherStack);

   return *this;
}

#endif


weno se agradece ...
salu...
17  Programación / Java / DUDA DE JAVA EN GENERAL en: 3 Mayo 2010, 03:55 am
weno amigos tengo varias dudas sobre java
weno la primera
es
para que sirve el try-catch
dicen que para las excepciones
pero cuando lleva
IOException ex cual es la diferencia con Exception e
x que e visto varios ejercicios
y son diferentes
y la otra es
como ingreso enteros
cadenas
de la forma mas facil
x que de la que me enseñaron es muy larga y me pierdo :S
salu...
18  Foros Generales / Dudas Generales / Re: error con el framework en: 3 Mayo 2010, 02:59 am
weno gracias ya lo solucione
tenia el error 1603
utilise el windows install clean up
reinicie mi makina y de maravilla
me instalo
:D
gracias manes
salu que les vaya bien :D
19  Foros Generales / Dudas Generales / error con el framework en: 1 Mayo 2010, 20:34 pm
olaz amigos quiero
instalar un programa
que es el visual studio 2008 ya que lo necesito
y cuando intento instalar falla la instalacion x el framework 3.5
lei en otros foros
que tenia que kitar todos los frameworks que tenia
asi que desinstale el 2.0 que tenia
y lei
que tenia que kitar todo lo que kede
ya pz
y ahora me sale el mismo error
osea
antes de instalar el framewokr 3.5
cuales tengo que instalar primero
...
salu...
20  Programación / Programación C/C++ / Re: |Lo que no hay que hacer en C/C++. Nivel basico| en: 6 Abril 2010, 17:12 pm
una pregunta
no se muxo de c++
pero si no pones el system pause
en un bucle x ejemplo menu
se borra y no sale la respuesta
y tu tambien pusiste que no se deve usar el getch
tons que uso para que no se borre el resultado...
:S
Páginas: 1 [2] 3
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines