SoloCodigo
Programación General => C/C++ => Mensaje iniciado por: Meri en Domingo 30 de Noviembre de 2003, 20:27
-
hola a tod@s!! Tengo un pequeño (pero para mi, gran problema) con este programilla :unsure: . Tengo que hacer el menu de un movil... todo va bien excepto que no me entra la opcion 3.total de llamadas y que cuando acabo de una opcion vuelve al menu pero se bloquea y yo no kiero que se bloquee sino que siga.
Alguien me puede ayudar a solucionarlo??
Muxas gracas a tod@s!!! :good:
-
pon el codigo y te digo donde esta el fallo :P
es simple con un simple switch se puede hacer.
-
Sin el código del programa será dificil ayudarte... Un saludo :lightsabre:
-
si te sirbe esto de algo ....
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int opcion1()
{
clrscr();
char sal='n';
printf("OPCION 1");
printf("\n");
printf("Pulse una tecla para continuar.");
getche();
clrscr();
do
{
resp='s';
// aqui pones tu primera opcion del movil ...
printf("\n");
printf("\n ¿ Desea volver al menu principal ? (s/n): ");
sal=getche();
}while (sal!='s');
return(0);
}
int opcion2()
{
clrscr();
char resp='n';
printf("OPCION 2");
printf("\n");
printf("Pulse una tecla para continuar.");
getche();
while (resp!='s')
{
// aqui pones tu segunda opcion ...
do{
printf("\n ¿ Desea volver al menu principal ? (s/n): ");
resp=getche();
}while ((resp!='s') && (resp!='n'));
}
return(0);
}
void main()
{
int num;
char resp='n';
clrscr();
while (resp!='s')
{
clrscr();
printf("\nMOVIL \n");
printf("\n------------------------\n");
printf("\n");
printf("\n -Selecciona una opcion- \n");
printf("\n");
printf(" 1. OPCION1.\n");
printf(" 2. OPCION2.\n");
printf("\n");
printf("OPCION: ");
scanf("%d", &num);
switch ( num )
{
case 1:
opcion1 ();
break;
case 2:
opcion2 ();
break;
default:
do{
printf("Opcion incorrecta!\n");
printf("\nTeclee otro numero (1/2) segun las opciones: ");
scanf("%d", &num);
if (num==1)
{
opcion1();
break;
}
if (num==2){
opcion2();
break;
}
}while ((num!=1) || (num!=2));
}
clrscr();
printf("\n¿ Desea apagar el movil ? (s/n): ");
resp=getche();
}
}
-
ESTE ES EL CODIGO... VAYA FALLO K HE TENIDO AL NO PONERLO ;) !!!!
#include<stdio.h>
#include<conio.h>
void menu (char *opcion)
{
printf("\n-----------------------------------------------------------------------------\n");
printf("\n1.LLAMADA REALIZADA\n2.LLAMADA RECIBIDA\n3.MOSTRAR TOTAL LLAMADAS\n4.ESTADO DE LA BATERIA\n5.RECARGAR BATERIA\n6.CALCULADORA\n7.SALIR\n");
printf("\n-----------------------------------------------------------------------------\n");
printf("\nESCOJA EL NUMERO DE LA OPCION DESEADA\n");
scanf("%c",opcion);
}
void main()
{
int a,b,t,H1,S1,M1,H2,M2,S2,c=0,g=0,r,i,H3,H4,M3,M4,S3,S4;
double tt,ttt,ti,tf,h1,h2,m1,m2,s1,s2,h3,h4,m3,m4,s3,s4,tir,tfr,ttr,tttr,p,w,bat;
char op,opcion;
clrscr();
menu(&opcion);
do
{
if(opcion=='1')
{
clrscr();
printf("\nINTRODUZCA HORA, MINUTO Y SEGUNDO DE INICIO DE LLAMADA REALIZADA\n");
scanf("%d,%d,%d",&H1,&M1,&S1);
printf("\nINTRODUZCA HORA, MINUTO Y SEGUNDO DE FINALIZACION DE LLAMADA REALIZADA\n");
scanf("%d,%d,%d",&H2,&M2,&S2);
h1=(double)H1;
h2=(double)H2;
m1=(double)M1;
m2=(double)M2;
s1=(double)S1;
s2=(double)S2;
h1=h1*3600;
m1=m1*60;
ti=h1+m1+s1;
h2=h2*3600;
m2=m2*60;
tf=h2+m2+s2;
tt=tf-ti;
if(tt>=0)
{
printf("\n LA LLAMADA REALIZADA DURO;%10.0f SEGUNDOS\n",tt);
c++;
}
else
if(tt<0)
{
tt=86400+tt;
printf("\n \n LA LLAMADA REALIZADA DURO;%10.0f SEGUNDOS\n",tt);
c++;
}
ttt=ttt+tt;
menu(&opcion);
}
if(opcion=='2')
{
clrscr();
printf("\nINTRODUZCA HORA, MINUTO Y SEGUNDO DE INICIO DE LLAMADA RECIBIDA\n");
scanf("%d,%d,%d",&H3,&M3,&S3);
printf("\nINTRODUZCA HORA, MINUTO Y SEGUNDO DE FINALIZACION DE LLAMADA RECIBIDA\n");
scanf("%d,%d,%d",&H4,&M4,&S4);
h3=(double)H3;
h4=(double)H4;
m3=(double)M3;
m4=(double)M4;
s3=(double)S3;
s4=(double)S4;
h3=h3*3600;
m3=m3*60;
tir=h3+m3+s3;
h4=h4*3600;
m4=m4*60;
tfr=h4+m4+s4;
ttr=tfr-tir;
if(ttr>=0)
{
printf("\n LA LLAMADA RECIBIDA DURO;%10.0f SEGUNDOS\n",ttr);
g++;
}
else
if(ttr<0)
{
ttr=86400+ttr;
printf("\n \n LA LLAMADA RECIBIDA DURO;%10.0f SEGUNDOS\n",ttr);
g++;
}
tttr=tttr+ttr;
menu(&opcion);
}
if(opcion=='3')
{
clrscr();
printf("\n EL NUMERO DE LLAMADAS REALIZADAS HA SIDO DE:%d\n",c);
printf("\n EL TIEMPO TOTAL DE TODAS SUS LLAMADAS REALIZADAS HA SIDO DE:%10.0f segundos\n",ttt);
clrscr();
printf("\n EL NUMERO DE LLAMADAS RECIBIDAS HA SIDO DE:%d\n",g);
printf("\n EL TIEMPO TOTAL DE TODAS SUS LLAMADAS RECIBIDAS HA SIDO DE:%10.0f segundos\n",tttr);
clrscr();
menu(&opcion);
}
if(opcion=='4')
{
w=ttt+tttr;
if(w>=18000)
{
printf("\a\n ALERTA!SIN BATERIA!\n\n");
printf("\n por favor elija la opcion cargar bateria\n");
}
if(w==0)
{
printf("\n LA BATERIA ESTA AL 100% DE SU CARGA\n");
}
if(w<18000)
{
p=(w*100)/18000;
bat=100-p;
printf("\n LA BATERIA ESTA AL %10.0f% DE SU CARGA\n",bat);
}
menu(&opcion);
}
if(opcion=='5')
{
c=0;
g=0;
tt=0;
ttr=0;
ttt=0;
tttr=0;
printf("\n LA BATERIA HA SIDO CARGADA AL 100% DE SU CAPACIDAD\n");
menu(&opcion);
}
if(opcion=='6')
{
clrscr();
printf("\n INTRODUZCA EL PRIMER VALOR:\n");
scanf("%d",&a);
printf("\n INTRODUZCA EL SEGUNDO VALOR:\n");
scanf("%d",&b);
printf("\n INTRODUZCA LA OPERACION A REALIZAR:\n");
scanf("%s",&op);
if(op=='+')
{
t=a+b;
printf("\n EL RESULTADO ES %d\n",t);
}
if(op=='-')
{
t=a-b;
printf("EL RESULTADO ES: %d\n",t);
}
if(op=='*')
{
t=0;
for(i=b;i>=1;i--)
{
t=t+a;
}
printf("EL RESULTADO ES: %d",t);
}
if(op=='/')
{
t=0;
if(b==0||a==0)
{
printf("\a\n\EL RESULTADO ES: %d\n\n",t);
}
else
{
while (a>=B)
{
a=a-b;
t++;
}
printf("\n\nEL RESULTADO ES: %d\n\n",t);
}
menu(&opcion);
}
}
if(opcion>'7')
{
printf("\a\n OPCION NO PERMITIDA \n\n");
menu(&opcion);
}
}
while (opcion!='7');
getche();
}
-
buff te aconsejo que pongas comentarios a tus programas, porque igual que yo ahora no se que significan las variables que usas... te puede pasar a ti mismo a la hora de ver el programa dentro de un tiempo !!!
bueno por lo que me parece a mi ... te falta usar unos break. espera que vea biene l codigo y te digo mas ...
-
Hola de nuevo!!
Muchas gracias a todos por vuestra ayuda y vuestros consejos!!! Ya he conseguido que me funcione bien... ahora tengo que pasar todos los if a funciones void pero espero consiguirlo yo sola ;)
De nuevo muchas gracias!! :beer:
:kiss:
:hola: