-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnt2_Segundos.c
57 lines (47 loc) · 1.07 KB
/
Ent2_Segundos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include "Entr2.h"
#define MSJ_SALIDA_HMS "H M S :\n""\n"
#define VALOR_MAX 86400
#define VALOR_MIN 0
typedef enum { ST_ERROR_NO_NUMERICO,
ST_ERROR_BUFFER,
ST_ERROR_RANGO,
ST_OK
} status_t;
status_t Validar_Entrada(void)
{
int n,c,k,i, comp[]={3600,60}, v[]={0,0,0};
printf(MSJ_INGRESO_SEG);
if(scanf("%d", &n)!=1){
fprintf(stderr, "%s : %s\n", MSJ_ERROR_PREFIJO, MSJ_ERROR_INGRESO_INVALIDO);
return ST_ERROR_NO_NUMERICO;
}
while((c=getchar())!= '\n' && c != EOF)
;
if (n<VALOR_MIN || n>VALOR_MAX)
{
printf("%s : %s", MSJ_ERROR_PREFIJO, MSJ_ERROR_RANGO);
return ST_ERROR_RANGO;
}
else
{
for (i=0;i<=1;i++)
{
while (n >= comp[i])
{
n = n - comp[i];
v[i]++;
}
}
v[2]=n;
printf("H M S :\n""\n");
for (k=0;k<=2;k++)
printf("%d ", v[k]);
return ST_OK;
}
}
int main()
{
Validar_Entrada();
}