+ 3
Can anyone write the code using radical operations???
6 Respostas
+ 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);
}
}
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)
0
what is c++ and in which type it is start and work
0
ようわからんん
0
Oikawa , я т а к т о ж е м о г у
0
Ysssssss