-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_1001.cpp
38 lines (32 loc) · 906 Bytes
/
task_1001.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
std::vector<double> read_numbers(std::istream& from) {
std::vector<double> numbers;
double tmp;
while (from >> tmp) {
numbers.push_back(tmp);
}
return numbers;
}
void print_numbers(const std::vector<double>& numbers, std::ostream& to) {
to << std::fixed << std::setprecision(4);
for (const auto& number:numbers) {
to << number << std::endl;
}
}
int main() {
// std::fstream from_file("../data/input_1001_1.txt");
// auto& from = from_file;
auto& from = std::cin;
std::vector<double> numbers = read_numbers(from);
std::vector<double> sqrt_numbers(numbers.rbegin(), numbers.rend());
for (auto& number:sqrt_numbers) {
number = std::sqrt(number);
}
print_numbers(sqrt_numbers, std::cout);
return 0;
}