#include #include #include #include #include void saveListToFile(const std::vector& data, const std::string& filename) { std::ofstream outFile(filename); if (outFile.is_open()) { for (const auto& value : data) { outFile << value << "\n"; } outFile.close(); } else { std::cerr << "Unable to open file"; } } void generateWaveform(const std::vector& data) { for (const auto& value : data) { int amplitude = static_cast(value * 10); // Scale for visibility std::cout << std::string(std::abs(amplitude), amplitude > 0 ? '+' : '-') << "\n"; } } int main() { std::vector data = {0.1, 0.4, 0.8, 0.5, -0.3, -0.7, -0.4, 0.2}; saveListToFile(data, "data.txt"); generateWaveform(data); return 0; }