Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IFF - Introdução à Programação
- //Slide - Página 61 - Exercício 3
- #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);
- h=Converter(h);
- setbuf(stdin,NULL);
- printf("São %d:%d %s.\n\nDeseja nova consulta?\n",h,m,time);
- gets(resposta);
- }while (stricmp(resposta,"sim")==0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment