Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Introdução à Programação
- //Lista de Exercícios - Exercício 98
- #include<stdio.h>
- #include<locale.h>
- #include<string.h>
- char time[2];
- int Converter(int h){
- if(h>12){
- h-=12;
- strcpy(time,"pm");
- }else{
- strcpy(time,"am");
- }
- return h;
- }
- int main(){
- setlocale(LC_ALL,"Portuguese");
- int h, m;
- char resposta[3];
- do{
- printf("\nEntre, respectivamente, com a hora e minutos: ");
- scanf("%d%d",&h,&m);
- if(h<24){
- if(m>59){
- h++;
- m-=60;
- }
- h=Converter(h);
- printf("São %d:%d %s.\n\n",h,m,time);
- }else printf("Entre com um valor de hora válido.");
- setbuf(stdin,NULL);
- printf("Deseja nova consulta?\n",time);
- gets(resposta);
- }while (stricmp(resposta,"sim")==0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment