|
|
вернуться в форумWhy? Why this #include <math.h> #include <iostream> #include <iomanip> #include <vector> using namespace std; int main() { vector<double> numbers; double number = 0; while(cin >> number){ numbers.push_back(number); }
for(int i = numbers.size() - 1; i >= 0 ; i--){ cout<<setprecision(5)<<sqrt(numbers[i])<<'\n'; }
return 0; } is wrong and this //... printf("%.4lf\n", sqrt(numbers[i])); //... is write? I don't understand. Both ways are correct... Re: Why? I don't know C++ a lot, but I think setprecision(5) means at most 5 digits. So use this instead and be happy: cout<<setprecision(5)<<setiosflags(ios::fixed)<<sqrt(numbers[i])<<'\n'; in which setiosflags(ios::fixed) means there must be 5 digits, filling with zero, which will satisfy the judge. Edited by author 04.01.2010 18:41 Edited by author 04.01.2010 18:42 |
|
|