POLYTA_197711 de Julio del 2004
PreguntaAMIGOS, YA ME FALTA LO ULTIMO GRACIAS A SU AYUDA HE APRENDIDO MUCHO!!!!!! Y APARTE HE PODIDO AVANZAR, HE LOGRADO VALIDAR LOS MESES Y LA ENTRADA DE NUMEROS, PERO AHORA FALTA LO ULTIMO
-VALIDAR QUE NO ENTREN LETRAS
-VALIDAR QUE NO DEJE ESPACIOS
-VALIDAR QUE NO PRESIONE ENTER
AMIGOS REALMENTE FALTA ESTO SOLAMENTE, SI ALGUIEN PUEDE AYUDARME COMO SIEMPRE LO HAN ECHO ORIENTARME SE LO AGRADEZCO MUCHO.
MIREN EL CODIGO QUE ESTA ES EL SIGUIENTE, LA IDEA ES QUE LA VALIDACION QUEDE DENTRO DEL CODIGO POR FAVOR!!!!!
CUANDO LO TENGA LISTO AMIGOS, AUNQUE NO PUEDAN AYUDARME LO PONDRE ACA PORQUE SE LO MERECEN!!!!!!!
SALUDOS....................
#include<dos.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<conio.h>
struct date fecha;
int ValidarDia();
int meses[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int fnc_fecha();
int dia;
void fnc_hora();
int main()
{
char opcion;
do
{
clrscr();
gotoxy(35,2);
printf("RUTINA DE FECHAn");
gotoxy(25,10);
printf("1.- Fecha n");
gotoxy(25,12);
printf("2.- Hora n");
gotoxy(25,14);
printf("3.- Salirn ");
opcion=getchar();
if (opcion=='1')
{
/* if(fnc_fecha()==0)
{
gotoxy(25,15);
printf("nError El mes '%d' solo admite %d dias",fecha.da_mon,meses[fecha.da_mon-1]);;
printf("n pulsar una tecla para continuar ....");
getch();
fnc_fecha();
}*/
fnc_fecha();
// main();
}
else if(opcion=='2')
fnc_hora();
}
while(opcion!='3');
exit(0);
return 1;
}
int fnc_fecha()
{
clrscr();
int dia; int mes; int ano;
getdate(&fecha);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy (1,3);
printf("Su fecha actual es: %d-%d-%d",fecha.da_day, fecha.da_mon,fecha.da_year);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,4);printf(" Ingrese nuevo dia :");
scanf("%d",&dia);
while (dia<0 || dia>31)
{
gotoxy(40,4);printf("Dia fuera de rango (0-31)");
delay(2000);
fnc_fecha();
}
fecha.da_day=dia;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,5);printf(" Ingrese nuevo mes :");
scanf("%d",&mes);
while (mes<0 || mes>12)
{
gotoxy(40,5);printf("Mes fuera de rango (1-12)");
delay(2000);
fnc_fecha();
}
while (mes==2 && dia>28)
{
gotoxy(40,5);printf("Mes con 28 dias");
delay(2000);
fnc_fecha();
}
while (mes==4 || mes==6 || mes==9 || mes==11 && dia>30)
{
gotoxy(40,5);printf("Mes con 30 dias");
delay(2000);
fnc_fecha();
}
fecha.da_mon=mes;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,6);printf(" Ingrese nuevo ano :");
scanf("%d",&ano);
while (ano<1980 || ano>2099)
{
gotoxy(40,6);printf("Ano fuera de rango (1980-2099)");
delay(2000);
fnc_fecha();
}
fecha.da_year=ano;
//+++++++++++++++++++++++++++++++++++++++++++++
if(ValidarDia())
fecha.da_day=dia;
else
return 0;
//++++++++++++++++++++++++++++++++++++++++++++
setdate(&fecha);
gotoxy(1,7);
printf("Su nueva fecha es: %d-%d-%dn",fecha.da_day, fecha.da_mon,fecha.da_year);
delay(2500);
main();
return 1;
}
//****************************************************************************
void fnc_hora()
{
clrscr();
int horas; int minutos; int segundos;
struct time hora;
gettime(&hora);
gotoxy(1,2);
printf("Su hora actual es: %u:%u:%u",hora.ti_hour, hora.ti_min,hora.ti_sec);
//++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,3);printf(" Ingrese nueva hora :");
scanf("%u",&horas);
while (horas<0 || horas>24)
{
gotoxy(40,3);printf("Hora fuera de rango (0-24)");
delay(2000);
fnc_hora();
}
hora.ti_hour=horas;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,4);printf(" Ingrese nuevos minutos :");
scanf("%u",&minutos);
while (minutos<0 || minutos>60)
{
gotoxy(40,4);printf("Minutos fuera de rango (0-60)");
delay(2000);
fnc_hora();
}
hora.ti_min=minutos;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,5);printf(" Ingrese nuevos segundos:");
scanf("%u",&segundos);
while (segundos<0 || segundos>60)
{
gotoxy(40,5);printf("Segundos fuera de rango (0-60)");
delay(2000);
fnc_hora();
}
hora.ti_sec=segundos;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
hora.ti_hour=horas;
hora.ti_min=minutos;
hora.ti_sec=segundos;
settime(&hora);
gotoxy(1,6);
printf("Su nueva hora es: %u:%u:%un",hora.ti_hour,hora.ti_min,hora.ti_sec);
delay(2500);
main();
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int ValidarDia()
{
if(dia<=meses[fecha.da_mon-1])
return 1;
else
return 0;
}
LES ENCARGO POR FAVOR!!!!!!!!! LO QUE MAS ME INTERESA ES LA ENTRADA DE LETRAS!!!!!! GRACIAS REALMENTE NO HE PODIDO HACERLA, TANTO EN LA FNC_FECHA COMO EN FNC_HORA.
-VALIDAR QUE NO ENTREN LETRAS
-VALIDAR QUE NO DEJE ESPACIOS
-VALIDAR QUE NO PRESIONE ENTER
AMIGOS REALMENTE FALTA ESTO SOLAMENTE, SI ALGUIEN PUEDE AYUDARME COMO SIEMPRE LO HAN ECHO ORIENTARME SE LO AGRADEZCO MUCHO.
MIREN EL CODIGO QUE ESTA ES EL SIGUIENTE, LA IDEA ES QUE LA VALIDACION QUEDE DENTRO DEL CODIGO POR FAVOR!!!!!
CUANDO LO TENGA LISTO AMIGOS, AUNQUE NO PUEDAN AYUDARME LO PONDRE ACA PORQUE SE LO MERECEN!!!!!!!
SALUDOS....................
#include<dos.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<conio.h>
struct date fecha;
int ValidarDia();
int meses[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int fnc_fecha();
int dia;
void fnc_hora();
int main()
{
char opcion;
do
{
clrscr();
gotoxy(35,2);
printf("RUTINA DE FECHAn");
gotoxy(25,10);
printf("1.- Fecha n");
gotoxy(25,12);
printf("2.- Hora n");
gotoxy(25,14);
printf("3.- Salirn ");
opcion=getchar();
if (opcion=='1')
{
/* if(fnc_fecha()==0)
{
gotoxy(25,15);
printf("nError El mes '%d' solo admite %d dias",fecha.da_mon,meses[fecha.da_mon-1]);;
printf("n pulsar una tecla para continuar ....");
getch();
fnc_fecha();
}*/
fnc_fecha();
// main();
}
else if(opcion=='2')
fnc_hora();
}
while(opcion!='3');
exit(0);
return 1;
}
int fnc_fecha()
{
clrscr();
int dia; int mes; int ano;
getdate(&fecha);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy (1,3);
printf("Su fecha actual es: %d-%d-%d",fecha.da_day, fecha.da_mon,fecha.da_year);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,4);printf(" Ingrese nuevo dia :");
scanf("%d",&dia);
while (dia<0 || dia>31)
{
gotoxy(40,4);printf("Dia fuera de rango (0-31)");
delay(2000);
fnc_fecha();
}
fecha.da_day=dia;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,5);printf(" Ingrese nuevo mes :");
scanf("%d",&mes);
while (mes<0 || mes>12)
{
gotoxy(40,5);printf("Mes fuera de rango (1-12)");
delay(2000);
fnc_fecha();
}
while (mes==2 && dia>28)
{
gotoxy(40,5);printf("Mes con 28 dias");
delay(2000);
fnc_fecha();
}
while (mes==4 || mes==6 || mes==9 || mes==11 && dia>30)
{
gotoxy(40,5);printf("Mes con 30 dias");
delay(2000);
fnc_fecha();
}
fecha.da_mon=mes;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,6);printf(" Ingrese nuevo ano :");
scanf("%d",&ano);
while (ano<1980 || ano>2099)
{
gotoxy(40,6);printf("Ano fuera de rango (1980-2099)");
delay(2000);
fnc_fecha();
}
fecha.da_year=ano;
//+++++++++++++++++++++++++++++++++++++++++++++
if(ValidarDia())
fecha.da_day=dia;
else
return 0;
//++++++++++++++++++++++++++++++++++++++++++++
setdate(&fecha);
gotoxy(1,7);
printf("Su nueva fecha es: %d-%d-%dn",fecha.da_day, fecha.da_mon,fecha.da_year);
delay(2500);
main();
return 1;
}
//****************************************************************************
void fnc_hora()
{
clrscr();
int horas; int minutos; int segundos;
struct time hora;
gettime(&hora);
gotoxy(1,2);
printf("Su hora actual es: %u:%u:%u",hora.ti_hour, hora.ti_min,hora.ti_sec);
//++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,3);printf(" Ingrese nueva hora :");
scanf("%u",&horas);
while (horas<0 || horas>24)
{
gotoxy(40,3);printf("Hora fuera de rango (0-24)");
delay(2000);
fnc_hora();
}
hora.ti_hour=horas;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,4);printf(" Ingrese nuevos minutos :");
scanf("%u",&minutos);
while (minutos<0 || minutos>60)
{
gotoxy(40,4);printf("Minutos fuera de rango (0-60)");
delay(2000);
fnc_hora();
}
hora.ti_min=minutos;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
gotoxy(1,5);printf(" Ingrese nuevos segundos:");
scanf("%u",&segundos);
while (segundos<0 || segundos>60)
{
gotoxy(40,5);printf("Segundos fuera de rango (0-60)");
delay(2000);
fnc_hora();
}
hora.ti_sec=segundos;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
hora.ti_hour=horas;
hora.ti_min=minutos;
hora.ti_sec=segundos;
settime(&hora);
gotoxy(1,6);
printf("Su nueva hora es: %u:%u:%un",hora.ti_hour,hora.ti_min,hora.ti_sec);
delay(2500);
main();
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int ValidarDia()
{
if(dia<=meses[fecha.da_mon-1])
return 1;
else
return 0;
}
LES ENCARGO POR FAVOR!!!!!!!!! LO QUE MAS ME INTERESA ES LA ENTRADA DE LETRAS!!!!!! GRACIAS REALMENTE NO HE PODIDO HACERLA, TANTO EN LA FNC_FECHA COMO EN FNC_HORA.
