#include <iostream>
int main(void)
{
auto pow_int = [] (int x, int y) {
int i, mult = 1;
for (i=0; i<y; i++)
mult *= x;
return mult;
};
auto get_sum = [] (int min, int max, bool is_even)
{
int i, sum = 0;
for (i=min; i<max+1; i++)
sum += (i%2==0 && is_even || i%2==1 && !is_even) ? i : 0;
return sum;
};
/* 1 */
std::cout << "1) " << get_sum(1, 10, true) << std::endl;
/* 2 */
int even_sum = get_sum(1, 100, false), odd_sum = get_sum(1, 100, true);
std::cout << "2) Odd: " << even_sum <<
", Even: " << odd_sum <<
", All: " << even_sum + odd_sum << std::endl;
/* 3 */
std::cout << "3) y = 5x + 8;" <<std::endl;
for (int i=0; i<=10; i++)
std::cout << "y=" << 5*i+8 << "[x=" << i << "]" << std::endl;
/* 4 */
int pow_sum = 0;
for (int j=10; j<=90; j+=20)
pow_sum += pow_int(j, 3);
std::cout << "4) " << pow_sum << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4odm9pZCkKewogIGF1dG8gcG93X2ludCA9IFtdIChpbnQgeCwgaW50IHkpIHsKICAgIGludCBpLCBtdWx0ID0gMTsKICAgIGZvciAoaT0wOyBpPHk7IGkrKykKICAgICAgbXVsdCAqPSB4OwogICAgcmV0dXJuIG11bHQ7CiAgfTsKCiAgYXV0byBnZXRfc3VtID0gW10gKGludCBtaW4sIGludCBtYXgsIGJvb2wgaXNfZXZlbikKICB7CiAgICBpbnQgaSwgc3VtID0gMDsKICAgIGZvciAoaT1taW47IGk8bWF4KzE7IGkrKykKICAgICAgc3VtICs9IChpJTI9PTAgJiYgaXNfZXZlbiB8fCBpJTI9PTEgJiYgIWlzX2V2ZW4pID8gaSA6IDA7CiAgICByZXR1cm4gc3VtOwogIH07CgogIC8qIDEgKi8KICBzdGQ6OmNvdXQgPDwgIjEpICIgPDwgIGdldF9zdW0oMSwgMTAsIHRydWUpIDw8IHN0ZDo6ZW5kbDsKCiAgLyogMiAqLwogIGludCBldmVuX3N1bSA9IGdldF9zdW0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