Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - Giankaa

#1
Este es el código que uso para leer el archivo mp3, pueden probarlo y les muestra los tag,s título, album, los priv, todo, esta para la versión de ID3v2.3.0, espero puedan ayudarme, lo que se quiere es que se le va a mostrar al usuario algo así, ejemplo:
Nombre de la canción: cancionblablabla
Álbum: blablba
Año: 1997
entonces esos datos entran como tag a la canción, gracias.
Código (cpp) [Seleccionar]
#include <iostream>
#include <cstring>
#include <fstream>

using namespace std;
//-------------------------------------------------------------------------
typedef unsigned char byte;
typedef unsigned int uint;
typedef struct synch {
    byte b3,b2,b1,b0;
} sint;
//-------------------------------------------------------------------------
struct header
{
    char mark[3];
    byte version[2];
    byte flags;
    sint size;
};
//-------------------------------------------------------------------------
struct frame
{
    char id[4];
    sint size;
    byte flags[2];
};
//-------------------------------------------------------------------------
uint usych(sint value)
{
    return value.b0|value.b1<<8|value.b2<<16|value.b3<<24;
}
//-------------------------------------------------------------------------
int main()
{
    FILE *file=fopen("D:/Programacion/P1/ID3/cancion.mp3","r");
    if(!file)
    {
        cout<<"File not found"<<endl;
        return 0;
    }
    header hd;
    fread(&hd,10,1,file);
    if(strncmp(hd.mark,"ID3",3)!=0)
    {
        cout << "This file hasn't TAG" << endl;
        fclose(file);
        return 0;
    }
    cout << "Version :         "<< (int)hd.version[0]<<"."<<(int)hd.version[1] << endl;
    cout << "Flags :           "<< (int)hd.flags << endl;
    cout << "size :            " << usych(hd.size)<< endl;

    if(hd.version[0] < 3)
    {
        cout<<"Version doesn't match"<< endl;
        fclose(file);
        return 0;
    }
    char buffer;
    while(true)
    {
        frame fr;
        fread(&fr,10,1,file);
        if(fr.id[0]<'A')break;
        cout << endl << fr.id[0] << fr.id[1] << fr.id[2] << fr.id[3];
        cout <<"   "<< usych(fr.size)<<" bytes... ";
        if(fr.id[0]!='T'){
            fseek(file,usych(fr.size),SEEK_CUR);
            cout << "(Empty)" << endl;
        }else{
            cout << "(";
            for(uint i=0;i<usych(fr.size);i++)
            {
                fread(&buffer,1,1,file);
                if(buffer >= 32 && buffer <=126){
                    cout << buffer;
                }
            }
            cout << ")" << endl;
        }
    }
    cout << endl;

    fclose(file);

    return 0;
}
#2
Hola a todos, sucede que tengo problema con esta validación, el usuario no puede escribir ningun cosa diferente a los números de 0 a 9, sin embargo cuando ingreso por ejemplo 5asdf, si lo permite y necesito validar eso, he intentado mucho y no he podido, espero su ayuda gracias
Código (cpp) [Seleccionar]
#include <iostream>
#include <locale.h>
#include <string>
using namespace std;


//----------------------------------------------------------------------------------------------------------
string val(string n)
{
string c, p;
int i;
//
for (i = 0; i <= 10; i++)
{
c = n.at(i);
if (c != "0" && c != "1" && c != "2" && c != "3" && c != "4" && c != "5" && c != "6" && c != "7" && c != "8" && c != "9")
{
p = "0";
}
break;
}
return p;

}
//----------------------------------------------------------------------------------------------------------
void Units(string n)
{
if (n == "0") cout << "zero"; else
if (n == "1") cout << "one"; else
if (n == "2") cout << "two"; else
if (n == "3") cout << "three"; else
if (n == "4") cout << "four"; else
if (n == "5") cout << "five"; else
if (n == "6") cout << "six"; else
if (n == "7") cout << "seven"; else
if (n == "8") cout << "eight"; else
if (n == "9") cout << "nine";
}

//----------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------
void Tens(string n)
{
char t = n.at(0);
char u = n.at(1);
n = n.substr(1, 1);
//
if (t == '0' && u != '0')
{
Units(n);
}
if (t == '1')
{
if (u == '0') cout << "ten"; else
if (u == '1') cout << "eleven"; else
if (u == '2') cout << "twelve"; else
if (u == '3') cout << "thirteen"; else
if (u == '4') cout << "fourteen"; else
if (u == '5') cout << "fifteen";
else
{
Units(n);
cout << "teen";

}

}
if (t == '2')
{
if (u == '0') cout << "twenty";
else
{
cout << "twenty- ";
Units(n);
}
}
if (t == '3')
{
if (u == '0') cout << "thirty";
else
{
cout << "thirty-";
Units(n);
}
}
if (t == '4')
{
if (6u == '0') cout << "forty";
else
{
cout << "forty- ";
Units(n);
}
}
if (t == '5')
{
if (u == '0') cout << "fifty";
else
{
cout << "fifty-";
Units(n);
}
}
if (t == '6')
{
if (u == '0') cout << "sixty";
else
{
cout << "sixty-";
Units(n);
}
}
if (t == '7')
{
if (u == '0') cout << "seventy";
else
{
cout << "seventy-";
Units(n);
}
}
if (t == '8')
{
if (u == '0') cout << "eighty";
else
{
cout << "eighty-";
Units(n);
}
}
if (t == '9')
{
if (u == '0') cout << "ninety";
else
{
cout << "ninety-";
Units(n);
}
}

}

//--------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------
void Hundreds(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
n = n.substr(1, 2);

if (t == '0')
{
Tens(n);
}
if (t == '1')
{

if (u == '0'&& v == '0') cout << "One hundred";
else
{
cout << "One hundred and ";
Tens(n);
}
}
if (t == '2')
{
if (u == '0'&& v == '0') cout << "Two hundred";
else
{
cout << "Two hundred and ";
Tens(n);
}
}
if (t == '3')
{
if (u == '0'&& v == '0') cout << "Three hundred";
else
{
cout << "Three hundred and ";
Tens(n);
}
}
if (t == '4')
{
if (u == '0'&& v == '0') cout << "Four hundred";
else
{
cout << "Four hundred and ";
Tens(n);
}
}
if (t == '5')
{
if (u == '0'&& v == '0') cout << "Five hundred";
else
{
cout << "Five hundred and ";
Tens(n);
}
}
if (t == '6')
{
if (u == '0'&& v == '0') cout << "Six hundred";
else
{
cout << "Six hundred and ";
Tens(n);
}
}
if (t == '7')
{
if (u == '0'&& v == '0') cout << "Seven hundred";
else
{
cout << "Seven hundred and ";
Tens(n);
}
}
if (t == '8')
{
if (u == '0'&& v == '0') cout << "Eight hundred";
else
{
cout << "Eight hundred and ";
Tens(n);
}
}
if (t == '9')
{
if (u == '0'&& v == '0') cout << "Nine hundred";
else
{
cout << "Nine hundred and ";
Tens(n);
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------------------------------------------------
void Thousands(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
n = n.substr(1, 3);

if (t == '0')
{
Hundreds(n);
}
if (t == '1')
{
if (u == '0' && v == '0'&& w == '0') cout << "One thousand";
else
{
cout << "One thousand ";
Hundreds(n);
}
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0') cout << "Two thousand";
else
{
cout << "Two thousand ";
Hundreds(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0') cout << "three thousand";
else
{
cout << "three thousand ";
Hundreds(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0') cout << "four thousand";
else
{
cout << "four thousand ";
Hundreds(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0') cout << "five thousand";
else
{
cout << "five thousand ";
Hundreds(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0') cout << "six thousand";
else
{
cout << "six thousand ";
Hundreds(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0') cout << "seven thousand";
else
{
cout << "seven thousand ";
Hundreds(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0') cout << "eight thousand";
else
{
cout << "eight thousand ";
Hundreds(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0') cout << "nine thousand";
else
{
cout << "nine thousand ";
Hundreds(n);
}
}


}
//--------------------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------
void Thousands2(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
n = n.substr(1, 4);

if (t == '0')
{
Thousands(n);
}
if (t == '1')
{
string temp = "";
temp.resize(10);
temp[0] = t;
temp[1] = u;
temp[2] = v;
temp[3] = w;
temp[4] = x;
Tens(temp);
cout << " thousand ";
temp = &temp[2];
Hundreds(temp);
return;
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "twenty thousand";
else
{
cout << "twenty-";
Thousands(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "thirty thousand";
else
{
cout << "thirty-";
Thousands(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "forty thousand";
else
{
cout << "forty-";
Thousands(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "fifty thousand";
else
{
cout << "fifty-";
Thousands(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "sixty thousand";
else
{
cout << "sixty-";
Thousands(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "seventy thousand";
else
{
cout << "seventy-";
Thousands(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "eighty thousand";
else
{
cout << "eighty-";
Thousands(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "ninety thousand";
else
{
cout << "ninety-";
Thousands(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------
void Thousands3(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
char y = n.at(5);
n = n.substr(1, 5);

if (t == '0')
{
Thousands2(n);
}
if (t == '1')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "one hundred thousand ";
else
{
cout << "one hundred and ";
Thousands2(n);
}
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "two hundred thousand ";
else
{
cout << "two hundred and ";
Thousands2(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "three hundred thousand";
else
{
cout << "three hundred and ";
Thousands2(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "four hundred thousand";
else
{
cout << "four hundred and ";
Thousands2(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "five hundred thousand";
else
{
cout << "five hundred and ";
Thousands2(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "six hundred thousand";
else
{
cout << "six hundred and ";
Thousands2(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "seven hundred thousand";
else
{
cout << "seven hundred and ";
Thousands2(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "eight hundred thousand";
else
{
cout << "eight hundred and ";
Thousands2(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "nine hundred thousand";
else
{
cout << "nine hundred and ";
Thousands2(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------
void Millions(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
char y = n.at(5);
char z = n.at(6);
n = n.substr(1, 6);

if (t == '0')
{
Thousands3(n);
}
if (t == '1')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "one million ";
else
{
cout << "one million, ";
Thousands3(n);
}
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "two million ";
else
{
cout << "two million, ";
Thousands3(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "three million";
else
{
cout << "three million, ";
Thousands3(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "four million";
else
{
cout << "four million, ";
Thousands3(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "five million";
else
{
cout << "five million, ";
Thousands3(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "six million";
else
{
cout << "six million, ";
Thousands3(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "seven million";
else
{
cout << "seven million, ";
Thousands3(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "eight million";
else
{
cout << "eight million, ";
Thousands3(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "nine million";
else
{
cout << "nine million, ";
Thousands3(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------
void Millions2(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
char y = n.at(5);
char z = n.at(6);
char z2 = n.at(7);
n = n.substr(1, 7);

if (t == '0')
{
Millions(n);
}
if (t == '1')
{//11
string temp = "";//112000
temp.resize(10);
temp[0] = t;
temp[1] = u;
temp[2] = v;
temp[3] = w;
temp[4] = x;
temp[5] = y;
temp[6] = z;
temp[7] = z2;
Tens(temp);
cout << " million ";
temp = &temp[2];//12000000
Thousands3(temp);
return;
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "twenty million ";
else
{
cout << "twenty million ";
Millions(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "thirty million";
else
{
cout << "thirty million ";
Millions(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "forty million";
else
{
cout << "forty million ";
Millions(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "fifty million";
else
{
cout << "fifty million ";
Millions(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "sixty million";
else
{
cout << "sixty million ";
Millions(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "seventy million";
else
{
cout << "seventy million ";
Millions(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "eighty million";
else
{
cout << "eighty million ";
Millions(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "ninety million";
else
{
cout << "ninety million ";
Millions(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------
void Millions3(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
char y = n.at(5);
char z = n.at(6);
char z2 = n.at(7);
char z3 = n.at(8);
n = n.substr(1, 8);

if (t == '0')
{
Millions2(n);
}
if (t == '1')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "one hundred million ";
else
{
cout << "one hundred and ";
Millions2(n);
}
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "two hundred million ";
else
{
cout << "two hundred and ";
Millions2(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "three hundred million";
else
{
cout << "three hundred and ";
Millions2(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "four hundred million";
else
{
cout << "four hundred and ";
Millions2(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "five hundred million";
else
{
cout << "five hundred and ";
Millions2(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "six hundred million";
else
{
cout << "six hundred and ";
Millions2(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "seven hundred million";
else
{
cout << "seven hundred and ";
Millions2(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "eight hundred million";
else
{
cout << "eight hundred and ";
Millions2(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "nine hundred million";
else
{
cout << "nine hundred and ";
Millions2(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------
void Millions4(string n)
{
char t = n.at(0);
char u = n.at(1);
char v = n.at(2);
char w = n.at(3);
char x = n.at(4);
char y = n.at(5);
char z = n.at(6);
char z2 = n.at(7);
char z3 = n.at(8);
char z4 = n.at(8);
n = n.substr(1, 9);

if (t == '0')
{
Millions3(n);
}
if (t == '1')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "one billion ";
else
{
cout << "one billion, ";
Millions3(n);
}
}
if (t == '2')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "two billion ";
else
{
cout << "two billion, ";
Millions3(n);
}
}
if (t == '3')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "three billion";
else
{
cout << "three billion, ";
Millions3(n);
}
}
if (t == '4')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "four billion";
else
{
cout << "four billion, ";
Millions3(n);
}
}
if (t == '5')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "five billion";
else
{
cout << "five billion, ";
Millions3(n);
}
}
if (t == '6')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "six billion";
else
{
cout << "six billion, ";
Millions3(n);
}
}
if (t == '7')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "seven billion";
else
{
cout << "seven billion, ";
Millions3(n);
}
}
if (t == '8')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "eight billion";
else
{
cout << "eight billion, ";
Millions3(n);
}
}
if (t == '9')
{
if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "nine billion";
else
{
cout << "nine billion, ";
Millions3(n);
}
}


}
//-----------------------------------------------------------------------------------------------------------------------

int main()
{
int i, c;
string num, n, r, g;
//
cout << "===============================\n";
cout << "= Convert numbers to letters  =\n";
cout << "===============================\n\n";
do
{

do
{
cout << "Type a number up to 10 digits to convert in Written English: "; getline(cin, n);
c = n.size();
if (c == NULL) g = "0";
else g = val(n);
} while (c > 10 || g == "0");

switch (n.length())
{
case 1: Units(n); break;
case 2: Tens(n); break;
case 3: Hundreds(n); break;
case 4: Thousands(n); break;
case 5: Thousands2(n); break;
case 6: Thousands3(n); break;
case 7: Millions(n); break;
case 8: Millions2(n); break;
case 9: Millions3(n); break;
case 10: Millions4(n); break;
}

cout << endl;
cout << "Another number?:(Y/N) "; getline(cin, r);
} while (r == "y" || r == "Y");

cout << "\n\nHOMEWORK # 2\nAuthor: Giancarlo Rosero Portillo\nto: Jesus Insuasti\n";
system("pause");
return 0;
}
#3
Hola, vengo a pedir ayudaaaa :-( :-( alguien podría explicarme como funciona el método de ordenamiento quicksort usando la recursividad? He estado mucho tiempo intentando realizarlo pero no me sale, solo me da algún error y así, debo ingresar n números a un vector, luego ordenarlos por ese método, he visto vídeos y no me funcionan las cosas, quería ponerlo en diagrama de flujo para ver si entendía mejor pero nada, espero me ayuden pronto, tengo desesperación T.T :-( gracias...
#4
Dudas Generales / Valor absoluto
27 Febrero 2016, 23:55 PM
Hola, pueden ayudarme con algo que no entiendo... Es de valor absoluto:
Este es el punto:

|2x-1|x+1||=x-2

Tengo un buen poco de esos ejercicios pero con uno que sepa como se hace ya puedo hacer los otros, espero me ayuden, muchas gracias!
#5
Desarrollo Web / formulario en javascript
29 Noviembre 2015, 19:29 PM
Necesito ayuda, debo ingresar ciertos datos en un formulario y hacer una operación, el resultado de la operación que se muestre en un recuadro con la etiqueta <div>.
He hecho esto:
Código (html4strict) [Seleccionar]
<!DOCTYPE html>
<html>
<head>
<title>Trabajo Final</title>
<meta charset="utf-8">
<script type="text/javascript" src="../js/javascript.js"></script>
<link rel="stylesheet" type="text/css" href="../css/estilos.css">

</head>
<body>


   <form id="contacto-frm" name="contacto_frm" action="" method="get" enctype="application/x-www-form-urlencoded">
   <img src="imagen.jpg">
        <table sTYLE="table-layout:fixed">

        <tr>
        <td >
        <label for="lecturaactual">Lectura Actual  : </label>
        <input type="number" id="lecturaactual" name="lecturaactual_numb">
        </td>

        <td>
        <p>Consumo m3</p>

        <div id="consumo">0</div>
        </td>
        </tr>

        <tr>
        <td >
        <label for="lecturaanterior">Lectura Anterior: </label>
        <input type="number" id="lecturaanterior" name="lecturaanterior_numb">
        </td>

        <td>
        <p align="center">Subsidio</p>
        </td>
        <td>
        <p align="center">Contribución</p>
        </td>
        </tr>

        <tr>
          <td >
        <label for="estrato">Estrato </label>
        <select class="estilo" id="estrato" name="estrato">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
        </select>
          </td>

        <td >
        <div id="subsidio">0</div>
        </td>

        <td >
        <div id="contribucion">0</div>
        </td>

        </tr>
<tr>
  <td>
    <input type="button" id="agretabla" class="boton" name="agretabla_btn" value="Agregar a tabla +" >
  </td>
  <td>Valor Subtotal:</td>

  <td>
 
    <div>1564</div>
  </td>

  <td>
    <input type="button" id="calcular" class="boton" name="calcular_btn" value="Calcular" >
  </td>

</tr>

        </table>
        <table>
          <tr>
            <td>Estrato</td>
            <td>Consumo</td>
            <td>Subsidio/Contribución</td>
            <td>Subtotal</td>
          </tr>
          <tr>
            <td>adgf</td>
          </tr>

        </table>

   </form>
   <script type="text/javascript">
   var prinum=document.getElementById("lecturaactual");
   var segnum=document.getElementById("lecturaanterior");
   document.getElementById("consumo").innerHTML=" "+consumo(prinum,segnum);
   </script>
</body>
</html>


En el codigo javascript esto:

Código (javascript) [Seleccionar]
function agregartabla(){
alert("Validando");
}
function subtotal(){
//alert("Calculando");
var verificar=true;
var formulario=document.getElementById("contacto_frm");
var lecturaactual=document.getElementById("lecturaactual");
var lecturaanterior=document.getElementById("lecturaanterior");
if (lecturaactual.value=="") {
alert("El campo lectura actual es requerido");
lecturaactual.focus();
verificar=false;
}else if (isNaN(lecturaactual.value)) {
alert("El campo lectura actual Sólo acepta números");
lecturaactual.focus();
verificar=false;
}else if (lecturaanterior.value=="") {
alert("El campo lectura anterior es requerido");
lecturaanterior.focus();
verificar=false;
}else if (isNaN(lecturaanterior.value)) {
alert("El campo lectura anterior Sólo acepta números");
lecturaanterior.focus();
verificar=false;
}else if (lecturaanterior.value>lecturaactual.value) {
alert("El campo lectura anterior debe ser inferior al campo lectura actual");
lecturaanterior.focus();
verificar=false;
}
if (verificar==true) {
alert("Se ha enviado el formulario");
}

document.contacto_frm.submit();
}
window.onload=function(){
var botontabla, botonsubtotal;
botontabla=document.getElementById("agretabla");
botontabla.onclick=agregartabla;
botonsubtotal=document.contacto_frm.calcular_btn;
botonsubtotal.onclick=subtotal;
}
function consumo(x,y){
var s=x-y;
return s;
}


necesito que ese resultado, el del consumo se muestre en el recuadro del consumo. graciassssssssssss
#6
PHP / Envío de formulario por php
26 Septiembre 2015, 08:40 AM
Hola, estaba creando un formulario y quería que los datos se envíen al correo pero no sé que sucede y no me funciona, he intentado de todo pero no he podido, espero su ayuda. Este es el formulario:

Código HTML:
Código (html4strict) [Seleccionar]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="es-Es" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Registro</title>
<link href='http://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Indie+Flower' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'>
<style type="text/css">

   body {
       background:url(fondo.jpg) no-repeat fixed center;
       background-position:center;
   }
   form {
       background:#333333;
       width:360px;
       border:1px solid #4e4d4d;
       border-radius:3px;
       -moz-border-radius:3px;
       -webkit-border-radius:3px;
       margin:100px auto;
   }
   form h1 {
       text-align: center;
       color: #ffffff;
       font-weight:black;
       font-size:18pt;
       margin-left: 0px;
       margin-right: 30px;
       margin-top: 15px;
       margin-bottom: -40px;
       font-family: 'Rock Salt', cursive;
   }
   form input{
       width:280px;
       height:35px;
       padding:0px 10px;
       color:#6d6d6d;
       margin-top:10px;
       margin-bottom:5px;
       font-family: 'Reenie Beanie', cursive;
       font-size: 17pt;
   }
   form label{
       width:280px;
       height:35px;
       padding:0px 0px;
       color:#ffffff;
       text-align:center;
       font-family: 'Indie Flower', cursive;
   }
   form button{
       width: 135px;
       margin-top:5px;
       height:50px;
       border:1px solid #232323;
       color: %fff;
       box-shadow: 0px 2px 0px #000;
       -moz-box-shadow: 0px 2px 0px #000;
       -webkit-box-shadow: 0px 2px 0px #000;
       border-radius: 3px;
       -moz.border-radius: 3px;
       -webkit-border-radius: 3px;
   }
   form button:hover{
       background:#B2B2B2;
   }
   form button:active{
       background: #F9F9F9;
   }
</style>
</head>
<body>

<form method="post" action="miformu.php">
   <ul>      
           <h1><b> Registrese para mantenerse en contacto con nosotros</b><br /></h1><br />
     
      <br />
          <label for="name">Primer nombre:</label>
          <input type="text" name="nombre" placeholder="Ejm: Giancarlo" required />
     
      <br />
          <label for="name">Segundo nombre:</label>
          <input type="text" name="nombredos" placeholder="(Opcional)" />
     
      <br />
          <label for="text">Apellidos:</label>
          <input type="text" name="apellidos" placeholder="Ejm: Rosero Portillo" required />
     
      <br />
          <label for="date">Fecha de nacimiento:</label>
          <input type="date" name="nacimiento" name="nacimiento" required />
       
      <br />
          <label for="email">Email:</label>
      <br />
          <input type="email" name="email" placeholder="Ejm: giancarlo@ejemplo.com" required />
       
      <br />
          <label for="name">Ingrese un nombre de usuario:</label>
          <input type="text" name="usuario" placeholder="Nombre de usuario" required />

      <br />
          <label for="name">Ingrese una contraseña:</label>
          <input type="password" name="clave" required />            
     
      <br />
          <label for="Mensaje">Mensaje:</label> <br />
          <textarea name="Mensaje" name="opinion" placeholder="Escribenos tu opinión:" cols="40" rows="6"></textarea>
     
       <br />
         <input type="submit" value="enviar" id="boton">
       
   </ul>
</form>
</body>
</html>


Y en el php tengo esto:

Código PHP:

Código (php) [Seleccionar]
<?php
$destino
"correo@gmail.com";
 
$nombre=$_POST["nombre"];
$nombredos=$_POST["nombredos"];
$apellidos=$_POST["apellidos"];
$nacimiento=$_POST["nacimiento"];
$correo=$_POST["correo"];
$usuario=$_POST["usuario"];
$clave=$_POST["clave"];
$opinion=$_POST["opinion"];
$contenido"Nombre: " .$nombre"\nnombredos" .$nombredos"\nApellidos: " .$apellidos"\nNacimiento: " ."\nCorreo: " .$correo"\nUsuario: " .$usuario"\nClave: " .$clave"\nOpinion: " .$opinion;
mail($destino"Mensaje de prueba"$contenido);
echo 
"Se envió el mensaje";
?>


Según todo y eso sale que se ha enviado; pero NO LLEGA NADA
espero me ayuden, gracias

Mod: Post modificado quitando detalles personales no influyentes en la resolucion del problema
#7
PHP / Tablas de multiplicar php
20 Agosto 2015, 23:08 PM
Hola espero me ayuden, no comprendí un ejercicio del examen que debía realizar y por eso no obtuve una buena nota :(
El ejercicio decía así:
Realizar un formulario el cual reciba un valor X , ese valor es la tabla de multiplicar que el usuario desea consultar, esto se realiza con php, al calcular debe mostrar la tabla de multiplicar y automáticamente debe mostrar el valor inicial generado y el valor final generado a multiplicar, tenga en cuenta que el formulario solo recibe un valor y es el de la tabla a multiplicar, ejemplos:

Ejemplo 1:

Valor X : 8

La tabla de multiplicar del 8 desde 3 hasta 7 es :
Valor inicial generado: 3
Valor final generado: 7

8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56

Ejemplo 2:

Valor X : 12

La tabla de multiplicar del 12 desde 8 hasta 3 es :
Valor inicial generado: 8
Valor final generado: 3

12 x 8 = 96
12 x 7 = 84
12 x 6 = 72
12 x 5 = 60
12 x 4 = 48
12 x 3 = 36
#8
Hola, tengo una tarea pero no me sale    es la siguiente...
Debo realizar un formulario HTML que reciba "n" numeros aleatorios entre 1 y 100, eso lo tengo! Lo que me falta es que además de eso debo mostrar la suma de los números generados, el promedio de ellos, también cuál número es el mayor y cuál número es el menor.
Ej:
Digite el valor de n: 5
Los números generados son:
20
15
10
25
50
La suma de los números generados es: 120
El promedio: es 24
El número mayor es: 50
El número menor es: 10

Lo que llevo es esto: en el form html:
Código HTML:
Código (html4strict) [Seleccionar]
<form action="clase11b.php">
    Digite el valor de n:
    <input type="number" name="valorn"><br />
    <input type="submit" value="Procesar"><br />
</form>

Y para el php esto:

Código PHP:
Código (php) [Seleccionar]
<?php
$n
=$_GET["valorn"];
echo 
"Estos son $n numeros aleatorios entre 1 y 100 <br />";
$cantidad=1;
$suma=1;
while (
$cantidad<=$n){
    
$rand=rand(1,100);
    echo 
"Numero aleatorio $rand <br />";
    ++
$cantidad;
    
}
$suma+=$cantidad;
echo 
"La suma de los n&uacute;meros generados es $suma <br />"
?>

Me ayudan? Porfavorrrrrrrrrrr :c