-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-1.c
55 lines (48 loc) · 1.08 KB
/
5-1.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
/*Escribir una función que convierta un número que representa una cantidad de segundos,
a su equivalente en horas, minutos y segundos, retornando las partes por la interfaz,
status_t por el nombre, indicando el resultado de la operación.
Realizar las validaciones pertinentes.*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define CANT 5
#define MSJ_ERROR "ERROR"
typedef enum{
ST_OK,
ST_NO_OK
}status_t;
/*status_t convertir (int v[], int CANT, int segundos){
int seg, min, hor;
if (CANT<3 || segundos<0 ){
fprintf(stderr, "%s\n", MSJ_ERROR);
}
min=segundos/60;
hor=min/60;
min=min%60;
seg=segundos&60;
v[0]=hor;
v[1]=min;
v[2]=hor;
return v;
}
*/
/****************** ooooooooooooooooooooooooo ****************/
status_t convertir (int segundos){
int seg=0, min=0, hor=0;
if ( segundos<0 ){
fprintf(stderr, "%s\n", MSJ_ERROR);
return ST_NO_OK;
}
min=segundos/60;
hor=min/60;
min=min%60;
seg=segundos%60;
printf("%i:%i:%i\n",hor,min,seg );
return ST_OK;
}
int main(void){
srand (time (NULL));
convertir(rand() );
return 0;
}