1) x = -10, y1 = 100, y2 = -11
2) x = -9, y1 = 81, y2 = -9
3) x = -8, y1 = 64, y2 = -7
4) x = -7, y1 = 49, y2 = -5
5) x = -6, y1 = 36, y2 = -3
6) x = -5, y1 = 25, y2 = -1
7) x = -4, y1 = 16, y2 = 1
8) x = -3, y1 = 9, y2 = 3
9) x = -2, y1 = 4, y2 = 5
10) x = -1, y1 = 1, y2 = 7
11) x = 0, y1 = 0, y2 = 9
12) x = 1, y1 = 1, y2 = 11
13) x = 2, y1 = 4, y2 = 13
14) x = 3, y1 = 9, y2 = 15
15) x = 4, y1 = 16, y2 = 17
16) x = 5, y1 = 25, y2 = 19
17) x = 6, y1 = 36, y2 = 21
18) x = 7, y1 = 49, y2 = 23
19) x = 8, y1 = 64, y2 = 25
20) x = 9, y1 = 81, y2 = 27
21) x = 10, y1 = 100, y2 = 29
22) x = 11, y1 = 121, y2 = 31
Объяснение:
Программа написана на DevC++.
Если я правильно понял, то:
#include <iostream>
int main()
{
using Type = double;
auto function = []() -> Type
uint8_t
a{ 0 },
b{ 0 };
Type accumulate{ 0 };
for (uint8_t i = 1; i <= 30; ++i)
if (i & 1) // isEven
accumulate += (i / 2) - ((static_cast<Type>(i) - 1.2));
else
accumulate += ((static_cast<Type>(i) + 1.2) - i);
// debug std::cout << static_cast<int>(i) << " : " << accumulate << std::endl;
}
return accumulate;
};
std::cout << std::endl << "Result = " << function() << std::endl;
1) x = -10, y1 = 100, y2 = -11
2) x = -9, y1 = 81, y2 = -9
3) x = -8, y1 = 64, y2 = -7
4) x = -7, y1 = 49, y2 = -5
5) x = -6, y1 = 36, y2 = -3
6) x = -5, y1 = 25, y2 = -1
7) x = -4, y1 = 16, y2 = 1
8) x = -3, y1 = 9, y2 = 3
9) x = -2, y1 = 4, y2 = 5
10) x = -1, y1 = 1, y2 = 7
11) x = 0, y1 = 0, y2 = 9
12) x = 1, y1 = 1, y2 = 11
13) x = 2, y1 = 4, y2 = 13
14) x = 3, y1 = 9, y2 = 15
15) x = 4, y1 = 16, y2 = 17
16) x = 5, y1 = 25, y2 = 19
17) x = 6, y1 = 36, y2 = 21
18) x = 7, y1 = 49, y2 = 23
19) x = 8, y1 = 64, y2 = 25
20) x = 9, y1 = 81, y2 = 27
21) x = 10, y1 = 100, y2 = 29
22) x = 11, y1 = 121, y2 = 31
Объяснение:
Программа написана на DevC++.
Если я правильно понял, то:
#include <iostream>
int main()
{
using Type = double;
auto function = []() -> Type
{
uint8_t
a{ 0 },
b{ 0 };
Type accumulate{ 0 };
for (uint8_t i = 1; i <= 30; ++i)
{
if (i & 1) // isEven
accumulate += (i / 2) - ((static_cast<Type>(i) - 1.2));
else
accumulate += ((static_cast<Type>(i) + 1.2) - i);
// debug std::cout << static_cast<int>(i) << " : " << accumulate << std::endl;
}
return accumulate;
};
std::cout << std::endl << "Result = " << function() << std::endl;
}