This commit is contained in:
Peter 2021-12-04 21:30:27 +08:00
parent 30b223a5f3
commit 604bc29b90
4 changed files with 13 additions and 13 deletions

View File

@ -6,8 +6,8 @@ int main(int argc, char const *argv[])
{ {
FILE *p_file = fopen("input", "r"); FILE *p_file = fopen("input", "r");
char line[50]; char line[50];
uint increases = 0; unsigned int increases = 0;
uint previous_depth = 0; unsigned int previous_depth = 0;
while (fgets(line, sizeof line, p_file) != NULL) while (fgets(line, sizeof line, p_file) != NULL)
{ {
if (atoi(line) > previous_depth) if (atoi(line) > previous_depth)

10
1/1-2.c
View File

@ -8,8 +8,8 @@
typedef struct typedef struct
{ {
uint sum; unsigned int sum;
uint count; unsigned int count;
bool written; // IGNORE COMPARISONS AT THE START. bool written; // IGNORE COMPARISONS AT THE START.
} MEASUREMENT_WINDOW; } MEASUREMENT_WINDOW;
@ -17,14 +17,14 @@ int main(int argc, char const *argv[])
{ {
FILE *p_file = fopen("input", "r"); FILE *p_file = fopen("input", "r");
char line[50]; char line[50];
uint increases = 0; unsigned int increases = 0;
MEASUREMENT_WINDOW windows[N_WINDOWS]; MEASUREMENT_WINDOW windows[N_WINDOWS];
uint i = 0; unsigned int i = 0;
while (fgets(line, sizeof line, p_file) != NULL) while (fgets(line, sizeof line, p_file) != NULL)
{ {
uint n = atoi(line); unsigned int n = atoi(line);
// UPDATE MEASURING WINDOWS // UPDATE MEASURING WINDOWS
for (size_t j = 0; j < N_WINDOWS; j++) for (size_t j = 0; j < N_WINDOWS; j++)
{ {

View File

@ -7,8 +7,8 @@ int main(int argc, char const *argv[])
{ {
FILE *p_file = fopen("input", "r"); FILE *p_file = fopen("input", "r");
uint n_one[WIDTH] = {0}; unsigned int n_one[WIDTH] = {0};
uint length = 0; unsigned int length = 0;
char line[WIDTH + 2]; char line[WIDTH + 2];
while (fgets(line, sizeof line, p_file) != NULL) while (fgets(line, sizeof line, p_file) != NULL)
@ -24,8 +24,8 @@ int main(int argc, char const *argv[])
} }
// GET GAMMA/EPSILON // GET GAMMA/EPSILON
uint gamma = 0, epsilon = 0; unsigned int gamma = 0, epsilon = 0;
uint place = 1; unsigned int place = 1;
for (size_t i = WIDTH; i--;) for (size_t i = WIDTH; i--;)
{ {
if (n_one[i] > length / 2) if (n_one[i] > length / 2)

View File

@ -67,8 +67,8 @@ LIST *read_file(char *path)
char common_value(LIST *list, char index) char common_value(LIST *list, char index)
{ {
uint one = 0; unsigned int one = 0;
uint zero = 0; unsigned int zero = 0;
for (size_t i = 0; i < list->size; i++) for (size_t i = 0; i < list->size; i++)
{ {
if (list->list[i][index] - '0') if (list->list[i][index] - '0')