コード例 #1
0
ファイル: Evaluador.cpp プロジェクト: JSalazr/Examne2
void evaluar()
{
    int nota = 0;

    escribir("archivo_evaluador1",new Gato(5,'f',"ruru","persa"),1);
    escribir("archivo_evaluador1",new Gato(7,'m',"roro","siames"),0);
    escribir("archivo_evaluador1",new Gato(3,'f',"rara","bengala"),2);


    cout<<"Ejercicio escribir() y leer():\t\t";
    bool correcto = true;

    if(  (leer("archivo_evaluador1",0)->edad == 7
       && leer("archivo_evaluador1",1)->edad == 5
       && leer("archivo_evaluador1",2)->edad == 3
       && leer("archivo_evaluador1",0)->sexo == 'm'
       && leer("archivo_evaluador1",1)->sexo == 'f'
       && leer("archivo_evaluador1",2)->sexo == 'f'
       && leer("archivo_evaluador1",0)->nombre == "roro"
       && leer("archivo_evaluador1",1)->nombre == "ruru"
       && leer("archivo_evaluador1",2)->nombre == "rara"
       && leer("archivo_evaluador1",0)->raza == "siames"
       && leer("archivo_evaluador1",1)->raza == "persa"
       && leer("archivo_evaluador1",2)->raza == "bengala"
       )==false)
    {
        correcto=false;
    }

    escribir("archivo_evaluador2",new Gato(0,'m',"lolo","ragdoll"),0);
    escribir("archivo_evaluador2",new Gato(153,'f',"lola","sphinx"),1);

    if(  (leer("archivo_evaluador2",0)->edad == 0
       && leer("archivo_evaluador2",1)->edad == 153
       && leer("archivo_evaluador2",0)->sexo == 'm'
       && leer("archivo_evaluador2",1)->sexo == 'f'
       && leer("archivo_evaluador2",0)->nombre == "lolo"
       && leer("archivo_evaluador2",1)->nombre == "lola"
       && leer("archivo_evaluador2",0)->raza == "ragdoll"
       && leer("archivo_evaluador2",1)->raza == "sphinx"
       )==false)
    {
        correcto=false;
    }

    if(correcto)
    {
        nota+=4;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getPromedioDeEdad():\t\t";
    if(getPromedioDeEdad("archivo_evaluador1")==5
       &&getPromedioDeEdad("archivo_evaluador2")==76.5
       )
    {
        nota+=3;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    set<int>s1;
    s1.insert(1);
    s1.insert(2);
    s1.insert(3);
    s1.insert(4);

    set<int>s2;
    s2.insert(10);
    s2.insert(20);
    s2.insert(30);

    cout<<"Ejercicio getMayor():\t\t\t";
    if(getMayor(s1)==4
       && getMayor(s2)==30
       )
    {
        nota+=2;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    queue<char>q1;
    q1.push('a');
    q1.push('b');
    q1.push('c');
    q1.push('d');

    queue<char>q2;
    q2.push('q');
    q2.push('w');
    q2.push('e');
    q2.push('r');
    q2.push('t');

    stack<char>sq1;
    sq1.push('a');
    sq1.push('b');
    sq1.push('c');
    sq1.push('d');

    stack<char>sq2;
    sq2.push('q');
    sq2.push('w');
    sq2.push('e');

    cout<<"Ejercicio mezclarAlphabeticamente():\t";

    set<char> rs1 = mezclarAlfabeticamente(q1,sq1);
    set<char> rs2 = mezclarAlfabeticamente(q2,sq2);
    set<char> rs3 = mezclarAlfabeticamente(q1,sq2);

    if(rs1.size()==4
       && rs2.size()==5
       && rs3.size()==7

       && rs1.find('a')!=rs1.end()
       && rs1.find('e')==rs1.end()

       && rs2.find('q')!=rs2.end()
       && rs2.find('a')==rs2.end()
       && rs2.find('w')!=rs2.end()
       && rs2.find('e')!=rs2.end()
       && rs2.find('r')!=rs2.end()
       && rs2.find('t')!=rs2.end()

       && rs3.find('a')!=rs3.end()
       && rs3.find('e')!=rs3.end()
       )
    {
        nota+=2;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio existe():\t\t\t";

    vector<string>v1;
    v1.push_back("a");
    v1.push_back("b");
    v1.push_back("c");
    vector<string>v2;
    v2.push_back("1");
    v2.push_back("2");
    v2.push_back("3");
    v2.push_back("4");
    vector<string>v3;
    v3.push_back("q");
    v3.push_back("w");

    map<string,vector<string> >m1;
    m1["x"]=v1;
    m1["y"]=v2;

    map<string,vector<string> >m2;
    m2["A"]=v1;
    m2["B"]=v2;
    m2["C"]=v3;

    map<string,vector<string> >m3;
    m3["X"]=v3;

    if(existe(m1,"a")
       && existe(m2,"a")
       && !existe(m3,"a")
       && existe(m1,"a")

       && existe(m1,"x")
       && existe(m1,"y")
       && !existe(m1,"z")
       && existe(m1,"b")
       && existe(m1,"c")
       && !existe(m1,"d")
       && !existe(m1,"0")
       && existe(m1,"1")
       && existe(m1,"2")
       && existe(m1,"3")
       && existe(m1,"4")
       && !existe(m1,"5")
       && !existe(m1,"6")

       && existe(m2,"A")
       && existe(m2,"B")
       && existe(m2,"C")
       && !existe(m2,"D")

       && existe(m3,"X")

       && existe(m3,"q")
       )
    {
        nota+=3;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    NodoTrinario* n1 = new NodoTrinario(1);
    NodoTrinario* n2 = new NodoTrinario(2);
    NodoTrinario* n3 = new NodoTrinario(3);
    NodoTrinario* n4 = new NodoTrinario(4);
    NodoTrinario* n5 = new NodoTrinario(5);
    NodoTrinario* n6 = new NodoTrinario(6);
    NodoTrinario* n7 = new NodoTrinario(7);
    NodoTrinario* n8 = new NodoTrinario(8);
    NodoTrinario* n9 = new NodoTrinario(9);
    NodoTrinario* n10 = new NodoTrinario(10);

    n1->izquierdo = n2;
    n1->medio = n3;
    n1->derecho = n4;

    n2->izquierdo = n5;
    n2->medio = n6;
    n2->derecho = n7;

    n3->izquierdo = n8;
    n3->medio = n9;
    n8->medio = n10;

    cout<<"Ejercicio getMayor():\t\t\t";
    if(getMayor(n1)==10
       && getMayor(n2)==7
       && getMayor(n3)==10
       && getMayor(n4)==4
       )
    {
        nota+=3;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    cout<<"Ejercicio buscarYReemplazar():\t\t";
    buscarYReemplazar(n1,1,13);
    buscarYReemplazar(n1,8,18);
    buscarYReemplazar(n1,4,666);
    if(n1->valor == 13
        && n8->valor == 18
        && n4->valor == 666
       )
    {
        nota+=3;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    cout<<"Ejercicio retener3Bits():\t\t";
    if(retener3Bits(8)==0
        && retener3Bits(3)==3
        && retener3Bits(9)==1
        && retener3Bits(147)==3
        && retener3Bits(254)==6
       )
    {
        nota+=2;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<endl<<"Nota: "<<nota<<"/15"<<endl;
}
コード例 #2
0
ファイル: Evaluador.cpp プロジェクト: azunigac/Tarea1
void evaluar()
{
    float nota = 0;


int sumar(int a, int b);
int restar(int a, int b);
int multiplicar(int a, int b);
int dividir(int a, int b);
int getMayor(int a, int b);
int getMenor(int a, int b);
int getMayor(int a, int b, int c);
void setValor(int arreglo[], int valor, int posicion);
int getValor(int arreglo[], int posicion);
int getMayor(int arreglo[], int tamano);
int getMenor(int arreglo[], int tamano);
int getPromedio(int arreglo[], int tamano);


    cout<<"Ejercicio sumar:\t\t";
    if(sumar(5,3)==8 && sumar(2,1)==3 && sumar(1000,1234)==2234)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    cout<<"Ejercicio restar:\t\t";
    if(restar(5,3)==2 && restar(2,1)==1 && restar(5,7)==-2)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio multiplicar:\t\t";
    if(multiplicar(5,3)==15 && multiplicar(2,1)==2 && multiplicar(5,-7)==-35)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    cout<<"Ejercicio dividir:\t\t";
    if(dividir(9,3)==3 && dividir(2,1)==2 && dividir(8,2)==4)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getMayor:\t\t";
    if(getMayor(9,3)==9 && getMayor(1,2)==2 && getMayor(8,2)==8 && getMayor(8,16)==16)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getMenor:\t\t";
    if(getMenor(9,3)==3 && getMenor(1,2)==1 && getMenor(8,2)==2 && getMenor(8,16)==8)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getMayor:\t\t";
    if(getMayor(9,3,5)==9 && getMayor(1,3,2)==3 && getMayor(2,8,2)==8 && getMayor(8,5,16)==16)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio setValor:\t\t";
    int arr[]={1,2,3};
    setValor(arr,4,1);
    setValor(arr,9,2);
    int arr2[]={10,20};
    setValor(arr2,30,1);
    if(arr[0]==1 && arr[1]==4 && arr[2]==9 && arr2[0]==10 && arr2[1]==30)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getValor:\t\t";
    int a1[]={3,4,2,1};
    int a2[]={10,20,30};
    if(getValor(a1,0)==3 && getValor(a1,1)==4 && getValor(a2,0)==10 && getValor(a2,1)==20)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    cout<<"Ejercicio getMayor:\t\t";
    if(getMayor(a1,4)==4 && getMayor(a2,3)==30)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getMenor:\t\t";
    if(getMenor(a1,4)==1 && getMenor(a2,3)==10)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getPromedio:\t\t";
    if(getPromedio && getPromedio(a2,3)==20)
    {
        nota+=0.5;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    int pl;
    cout<<endl<<"Nota: "<<nota<<"/6"<<endl;
    cin>>pl;

}
コード例 #3
0
ファイル: Evaluador.cpp プロジェクト: Driem/Archivos
void evaluar()
{
    int nota = 0;

    queue<string>mi_cola_str;
    mi_cola_str.push("A");
    mi_cola_str.push("B");
    mi_cola_str.push("C");

    queue<string>mi_cola_str2;
    mi_cola_str2.push("Hola");
    mi_cola_str2.push("Mundo");

    cout<<"Ejercicio getPrimerElemento:\t";
    if(getPrimerElemento(mi_cola_str)=="A" && getPrimerElemento(mi_cola_str2)=="Hola")
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getTamano:\t\t";
    if(getTamano(mi_cola_str)==3 && getTamano(mi_cola_str2)==2)
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio existeEnCola:\t\t";
    if(existeEnCola(mi_cola_str,"B")==true && existeEnCola(mi_cola_str2,"jeje")==false)
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }


    queue<int>mi_cola_int;
    mi_cola_int.push(1);
    mi_cola_int.push(2);
    mi_cola_int.push(3);

    queue<int>mi_cola_int2;
    mi_cola_int2.push(10);
    mi_cola_int2.push(20);

    cout<<"Ejercicio getMayor:\t\t";
    if(getMayor(mi_cola_int)==3 && getMayor(mi_cola_int2)==20)
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<"Ejercicio getMenor:\t\t";
    if(getMenor(mi_cola_int)==1 && getMenor(mi_cola_int2)==10)
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    queue<float>mi_cola_float;
    mi_cola_float.push(1);
    mi_cola_float.push(2);
    mi_cola_float.push(3);

    queue<float>mi_cola_float2;
    mi_cola_float2.push(10);
    mi_cola_float2.push(20);

    cout<<"Ejercicio getPromedio:\t\t";
    if(getPromedio(mi_cola_float)==2 && getPromedio(mi_cola_float2)==15)
    {
        nota++;
        cout<<"Correcto"<<endl;
    }else
    {
        cout<<"Incorrecto"<<endl;
    }

    cout<<endl<<"Nota: "<<nota<<"/6"<<endl;
}