-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcriterios.c
70 lines (58 loc) · 1.92 KB
/
criterios.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
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "criterios.h"
struct criterios
{
double danceability;
double energy;
int key;
double loudness;
int mode;
double speechiness;
double acousticness;
double instrumentalness;
double liveness;
double valence;
double bpm;
int time_signature;
};
// ============ ESTRUTURA ============
Criterios Criterios_constroi()
{
Criterios c = (Criterios)calloc(1, sizeof(struct criterios));
return c;
}
// ============ LEITURA ============
Criterios Criterios_le(Criterios c, FILE *f)
{
fscanf(f, "%lf;", &c->danceability);
fscanf(f, "%lf;", &c->energy);
fscanf(f, "%d;", &c->key);
fscanf(f, "%lf;", &c->loudness);
fscanf(f, "%d;", &c->mode);
fscanf(f, "%lf;", &c->speechiness);
fscanf(f, "%lf;", &c->acousticness);
fscanf(f, "%lf;", &c->instrumentalness);
fscanf(f, "%lf;", &c->liveness);
fscanf(f, "%lf;", &c->valence);
fscanf(f, "%lf;", &c->bpm);
fscanf(f, "%d\n", &c->time_signature);
return c;
}
// ============ FUNCIONALIDADES ============
void Lista_criterios(Criterios c)
{
printf(" -danceability: \033[90m%.2lf\033[0m;\n", c->danceability);
printf(" -energy: \033[90m%.2lf\033[0m;\n", c->energy);
printf(" -key: \033[90m%d\033[0m;\n", c->key);
printf(" -loudness: \033[90m%.2lf\033[0m;\n", c->loudness);
printf(" -mode: \033[90m%d\033[0m;\n", c->mode);
printf(" -speechiness: \033[90m%.2lf\033[0m;\n", c->speechiness);
printf(" -acousticness: \033[90m%.2lf\033[0m;\n", c->acousticness);
printf(" -instrumentalness: \033[90m%.2lf\033[0m;\n", c->instrumentalness);
printf(" -liveness: \033[90m%.2lf\033[0m;\n", c->liveness);
printf(" -valence: \033[90m%.2lf\033[0m;\n", c->valence);
printf(" -bpm: \033[90m%.2lf\033[0m;\n", c->bpm);
printf(" -time signature: \033[90m%d\033[0m;\n\n", c->time_signature);
}