diogoAlves

IFF/Introdução à Programação/Slide/Pag 61/Ex 3

Mar 8th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Slide - Página 61 - Exercício 3
  3. #include<stdio.h>
  4. #include<locale.h>
  5. #include<string.h>
  6.  
  7. char time[2];
  8. int Converter(int h){
  9.     if(h>12){
  10.         h-=12;
  11.         strcpy(time,"pm"); 
  12.     }else{
  13.         strcpy(time,"am");
  14.     }
  15.     return h;
  16. }
  17. int main(){
  18.     setlocale(LC_ALL,"Portuguese");
  19.     int h, m;
  20.     char resposta[3];
  21.     do{
  22.         printf("\nEntre, respectivamente, com a hora e minutos: ");
  23.         scanf("%d%d",&h,&m);
  24.         h=Converter(h);
  25.         setbuf(stdin,NULL);
  26.         printf("São %d:%d %s.\n\nDeseja nova consulta?\n",h,m,time);
  27.         gets(resposta);
  28.     }while (stricmp(resposta,"sim")==0);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment