C++

[email protected]
01 de Marzo del 2006
ESCRIBIR UN PROGRAMA QUE LEA UNA FECHA EN FORMATO DD-MM-AAAA-Y CALCULE EL NUMERO DE DIAS TRANSCURRIDOS DESDE EL DIA 1 DE ENERO DE ESE AÑO

Noel Solw
01 de Marzo del 2006
// program dias.cpp
// 28/2/2005
// written in borland c++ - ver 4.5

// C++
// Enviado por [email protected] el d?a 26 de febrero de 2006
// ESCRIBIR UN PROGRAMA QUE LEA UNA FECHA EN FORMATO DD-MM-AAAA-Y CALCULE EL
// NUMERO DE DIAS TRANSCURRIDOS DESDE EL DIA 1 DE ENERO DE ESE A?O

#include <iostream.h>
#include <iomanip.h>

struct Date
{
int year,
month,
day;
}; // STRUCT DATE

const int days[2][13] = {{365,31,28,31,30,31,30,31,31,30,31,30,31},
{366,31,29,31,30,31,30,31,31,30,31,30,31}};

int GetNum(char *msg,int bottom = 0,int top = 12)
{
int n = -1;
while(n < bottom || n > top)
{
cout << setw(35) << msg;
cin >> n;
}
return n;
} // GET NUM

int Bisiesto(unsigned int n)
{
if(n%100 == 0) // si es divisible por 100 solamente es bisiesto
return (n%400 == 0); // cuando es divisible por 400
return (n%4 == 0); // es bisiesto cuando se puede dividir por 4
} // BISIESTO

int Count(Date d,int i)
{
int sum = d.day; // calculo del numero de dias incluyendo
for(int j = 1;j < d.month;j++) // la fecha entrada por el usuario
sum += days[i][j]; // puede calcularse excluyendo esta fecha
return sum; // es decir un dia menos.
} // COUNT

int main()
{
Date d;
d.month = GetNum("number of month <0 for exit> : ");
while(d.month)
{
d.year = GetNum("year : ",1900,2100);
int bisiesto = Bisiesto(d.year);
d.day = GetNum("day : ",1,days[bisiesto][d.month]);
cout << setw(35) << "days until the given date : " << Count(d,bisiesto)
<< endl << endl;
d.month = GetNum("number of month <0 for exit> : ");
}
cout << endl << "end of program - good bye ! ! !" << endl;
return 0;
} // MAIN







carlos
01 de Marzo del 2006
Hola ese foro si sirve te envieron el codigo del programa y encontre tu foro!!. Bueno cuando llegues por favor llamame al celu que yo te devolvere.
Te amo con mi corazon y yo no puedo vivir sin ti me he dado cuenta con el viaje de este fin de semana
Carlos

luis
01 de Marzo del 2006
hey men encontre tu escondiste

ana
01 de Marzo del 2006
metal no sea tan hipocrita en decirme eso jajajaj