#include <stdio.h>
int main()
{
// 1から10までの整数のうち、偶数の合計を求めなさい。
int goukei = 0;
for (int i = 1; i <= 10; ++i)
goukei += i * !(i % 2);
printf("1から10までの整数のうち、偶数の合計=%d\n", goukei
);
// 1から100までの整数で、奇数だけの合計、偶数だけの合計、総合計をもとめよ;
int sum[3]= {0,0,0};
for (int i = 1; i <= 100; ++i) {
sum[0] += i * (i % 2);
sum[1] += i * !(i % 2);
sum[2] += i;
}
printf("1から100までの整数で、\n奇数だけの合計=%d\n偶数だけの合計=%d\n総合計=%d\n", sum
[0], sum
[1], sum
[2]);
// y=5x+8の値をxが0~10まで、1ずつ増やした時のyの値
printf("y=5x+8の値をxが0~10まで、1ずつ増やした時のyの値=\n"); for (int x = 0; x <= 10; ++x)
printf("x=%d, y=%d\n", x
, 5 * x
+ 8);
// 10^3+30^3+50^3+70^3+90^3の計算
int kei = 0;
for (int i = 10; i <= 90; i += 20) {
kei += i * i * i;
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CmludCBtYWluKCkKewogIC8vIDHjgYvjgokxMOOBvuOBp+OBruaVtOaVsOOBruOBhuOBoeOAgeWBtuaVsOOBruWQiOioiOOCkuaxguOCgeOBquOBleOBhOOAggogIGludCBnb3VrZWkgPSAwOwogIGZvciAoaW50IGkgPSAxOyBpIDw9IDEwOyArK2kpCiAgICBnb3VrZWkgKz0gaSAqICEoaSAlIDIpOwogIHByaW50ZigiMeOBi+OCiTEw44G+44Gn44Gu5pW05pWw44Gu44GG44Gh44CB5YG25pWw44Gu5ZCI6KiIPSVkXG4iLCBnb3VrZWkpOwoKICAvLyAx44GL44KJMTAw44G+44Gn44Gu5pW05pWw44Gn44CB5aWH5pWw44Gg44GR44Gu5ZCI6KiI44CB5YG25pWw44Gg44GR44Gu5ZCI6KiI44CB57eP5ZCI6KiI44KS44KC44Go44KB44KI77ybCiAgaW50IHN1bVszXT0gezAsMCwwfTsKICBmb3IgKGludCBpID0gMTsgaSA8PSAxMDA7ICsraSkgewogICAgc3VtWzBdICs9IGkgKiAoaSAlIDIpOwogICAgc3VtWzFdICs9IGkgKiAhKGkgJSAyKTsKICAgIHN1bVsyXSArPSBpOwogIH0KICBwcmludGYoIjHjgYvjgokxMDDjgb7jgafjga7mlbTmlbDjgafjgIFcbuWlh+aVsOOBoOOBkeOBruWQiOioiD0lZFxu5YG25pWw44Gg44GR44Gu5ZCI6KiIPSVkXG7nt4/lkIjoqIg9JWRcbiIsIHN1bVswXSwgc3VtWzFdLCBzdW1bMl0pOwoKICAvLyB5PTV4Kzjjga7lgKTjgpLvvZjjgYzvvJDvvZ7vvJHvvJDjgb7jgafjgIHvvJHjgZrjgaTlopfjgoTjgZfjgZ/mmYLjga7vvZnjga7lgKQKICBwcmludGYoInk9NXgrOOOBruWApOOCku+9mOOBjO+8kO+9nu+8ke+8kOOBvuOBp+OAge+8keOBmuOBpOWil+OChOOBl+OBn+aZguOBru+9meOBruWApD1cbiIpOwogIGZvciAoaW50IHggPSAwOyB4IDw9IDEwOyArK3gpCiAgICBwcmludGYoIng9JWQsIHk9JWRcbiIsIHgsIDUgKiB4ICsgOCk7CgogIC8vIDEwXjMrMzBeMys1MF4zKzcwXjMrOTBeM+OBruioiOeulwogIGludCBrZWkgPSAwOwogIGZvciAoaW50IGkgPSAxMDsgaSA8PSA5MDsgaSArPSAyMCkgewogICAga2VpICs9IGkgKiBpICogaTsKICAgIHByaW50ZigiJWReMysiLCBpKTsKICB9CiAgcHJpbnRmKCJcYj0lZFxuIiwga2VpKTsKICByZXR1cm4gMDsKfQo=
1から10までの整数のうち、偶数の合計=30
1から100までの整数で、
奇数だけの合計=2500
偶数だけの合計=2550
総合計=5050
y=5x+8の値をxが0~10まで、1ずつ増やした時のyの値=
x=0, y=8
x=1, y=13
x=2, y=18
x=3, y=23
x=4, y=28
x=5, y=33
x=6, y=38
x=7, y=43
x=8, y=48
x=9, y=53
x=10, y=58
10^3+30^3+50^3+70^3+90^3+=1225000