Alan Zanatta Posted October 29, 2011 Report Share Posted October 29, 2011 (edited) #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<Windows.h> //------------------------------------------------ int hora,min,seg,op,op2,soma; int hrdesp,mindesp,segdesp; //VARIAVEIS int h=0,m=0,s=0; //------------------------------------------------ int validahora() { if(hora > 23) { return 1; } return 0; } int validamin() { if(min > 59) { return 1; } return 0; } int validaseg() { if(seg > 59) { return 1; } return 0; } int main() { do { system("cls"); cprintf("\n RELÓGIO EM C\n\n"); cprintf(" [1] RELÓGIO(DESPERTADOR)\n"); printf(" [0] SAIR "); scanf("%d",&op); switch(op) { case 1: system("cls"); cprintf("\n RELÓGIO EM C\n\n"); printf(" HORAS: "); //HORA scanf("%d",&hora); if(validahora()) { system("cls"); printf("\n Hora invalida"); getch(); break; } printf(" MINUTOS: "); //MINUTOS scanf("%d",&min); if(validamin()) { system("cls"); printf("\n Minuto invalido"); getch(); break; } printf(" SEGUNDOS: "); //SEGUNDOS scanf("%d",&seg); if(validaseg()) { system("cls"); printf("\n Segundo invalido"); getch(); break; } h=hora; m=min; s=seg; printf("\n\n DESPERTADOR (1 SIM/2 não): "); scanf("%d",&op2); switch(op2) { case 1: system("cls"); printf("\n CONFIGURAR DESPERTADOR"); printf("\n\n HORA: "); scanf("%d",&hrdesp); printf(" MINUTOS: "); scanf("%d",&mindesp); soma=hrdesp+mindesp; break; } while(1) { Sleep(1000); //intervalo de 1 segundo para contagem s++; if (s>59) { s=0; m++; } if (m>59) { m=0; h++; } if (h>23) { h = 0; } system("cls"); printf("\n HR MIN SEG\n"); cprintf(" %.2d %.2d %.2d ",h,m,s); if(soma>1) { printf("| DESPERTADOR ATIVO %.2d:%.2d",hrdesp,mindesp); if(soma == h+m) { for(int i=0; i<10; i++) { system("cls"); printf("\n"); printf(" \n DESPERTADOR ",hrdesp,mindesp); system("cls"); printf("\a\n\n DESPERTADOR %.2d:%.2d",hrdesp,mindesp); } soma=0; } } } } }while(op != 0); return 0; } Edited November 15, 2011 by kuroi Adicionar tag CODE Quote Link to comment Share on other sites More sharing options...
0 mJi Posted October 29, 2011 Report Share Posted October 29, 2011 (edited) Ok, você postou o código...e agora?É dúvida? Contribuição? Problema?Ah, e evite variáveis globais. Edited October 29, 2011 by mJi Quote Link to comment Share on other sites More sharing options...
Question
Alan Zanatta
Adicionar tag CODE
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.