+ 3

Can anyone write the code using radical operations???

26th Jul 2018, 5:00 AM
Nguyễn Quang Huy
Nguyễn Quang Huy - avatar
6 odpowiedzi
+ 5
Rowan " And remember that √4 is the same thing as 4^(1/2) and 4^(0.5) " Despite the correctness, but it's less readable compare to sqrt(4). BTW, the performance difference between the pow() version is significant -- about 10 times or so worse than sqrt(). Nguyễn Quang Huy I can think of a simple one to storing the numbers in a range with non-square exponents for later use. int main() { constexpr int Max = 128; vector<int> nonSquare; nonSquare.reserve(Max); double result, tmpInt; for (int i = 1; i <= Max; ++i) { result = sqrt(i); if (modf(result, &tmpInt) != 0) nonSquare.push_back(i); } }
26th Jul 2018, 9:12 AM
Babak
Babak - avatar
0
Read up here on powers: https://en.cppreference.com/w/cpp/numeric/math/pow And remember that √4 is the same thing as 4^(1/2) and 4^(0.5)
26th Jul 2018, 5:15 AM
Rowan
Rowan - avatar
0
what is c++ and in which type it is start and work
26th Jul 2018, 9:12 AM
Neha Tripathi
Neha Tripathi - avatar
0
ようわからんん
26th Jul 2018, 9:51 AM
Oikawa Tetsu
Oikawa Tetsu - avatar
0
Oikawa , я т а к т о ж е м о г у
28th Sep 2018, 7:58 AM
[No Name]
0
Ysssssss
21st Jun 2019, 6:50 PM
Kaili