This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
college-work/Задания по C и C++/с (2024)/С(2024)/10.cpp
T

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;
}