Archived
39 lines
780 B
C++
39 lines
780 B
C++
#include <graphics.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <vector>
|
|
|
|
void drawBarChart(const std::vector<int>& temperatures) {
|
|
int x = 50;
|
|
|
|
for (int temp : temperatures) {
|
|
bar(x, 400 - temp * 2, x + 30, 400);
|
|
x += 40;
|
|
}
|
|
}
|
|
|
|
std::vector<int> readTemperatures(const std::string& filename) {
|
|
std::ifstream file(filename);
|
|
std::vector<int> temperatures;
|
|
int temp;
|
|
|
|
while (file >> temp) {
|
|
temperatures.push_back(temp);
|
|
}
|
|
|
|
return temperatures;
|
|
}
|
|
|
|
int main() {
|
|
int gd = DETECT, gm;
|
|
initgraph(&gd, &gm, "");
|
|
|
|
std::vector<int> temperatures = readTemperatures("temperatures.txt");
|
|
|
|
drawBarChart(temperatures);
|
|
|
|
getch();
|
|
closegraph();
|
|
return 0;
|
|
}
|