Square(n) Sum
Complete the square sum function so that it squares each number passed into it and then sums the results together.For example, for it should return 9 because 1^2 + 2^2 + 2^2 = 9.
#include <vector>
#include <cmath>
int square_sum(const std::vector<int>& numbers)
{
int res = 0, i;
for (i = 0; i < numbers.size(); i++)
{
res += pow(numbers.at(i), 2);
}
return res;
} lambda array:sum((map(lambda n:n*n,array))){:10_248:}
页:
[1]