Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <iomanip>
- using namespace std;
- void Print(const vector<string>& names, const vector <double>& values, int width)
- {
- cout << setfill('.');
- cout << left;
- for (const auto& n : names)
- {
- cout << setw(width) << n << ' ';
- }
- cout << endl;
- cout << fixed << setprecision(2);
- // потоковые манипуляторы
- // fixed 0.000005 vs 5e-06
- // setprecision кол - во знаков после запятой
- for (const auto& v : values)
- {
- // setw() сбрасывается после вывода первого значения
- cout << setw(width) << v << ' ';
- }
- }
- int main()
- {
- vector <string> names = { "a","b","c" };
- vector <double> values = { 5, 0.01, 0.000005 };
- Print(names, values, 10);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement