My old code
#include <stdio.h>
#include "temps.h"
constexpr int size = sizeof(temperatures) / sizeof(int);
int temperatures_cval[size];
int minimum;
void without_no_value(int size)
{
int temp = temperatures[0];
if (temperatures[0] == no_value)
{
temp = 0;
}
for (int i = 0; (i != size); i++)
{
if (temperatures[i] == no_value)
{
temperatures_cval[i] = temp;
}else
{
temperatures_cval[i] = temperatures[i];
temp = temperatures[i];
}
}
}
void find_min(const int array[], int size)
{
for (int i = 1; i < size; i++)
{
if (array[i] < minimum)
{
minimum = array[i];
}
}
}
void press(int n, char c)
{
for (int i = 0; i < n; ++i)
printf("%c", c);
}
void draw_graph(const int array[])
{
for (int i = 0; i < size; i++)
{
if (array[i] < 0)
{
int space_count = array[i] - minimum;
press(space_count, ' ');
press(array[i] * -1,'*');
printf("%c\n", '|');
}else
{
press(minimum * -1, ' ');
printf("%c", '|');
press(array[i], '*');
printf("\n");
}
}
}
int main()
{
without_no_value(size);
find_min(temperatures_cval, size);
draw_graph(temperatures_cval);
return 0;
}
trying to make it better