回答編集履歴

2

コードの修正

2021/06/30 18:00

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -4,17 +4,13 @@
4
4
 
5
5
  {
6
6
 
7
- int k, N = 10, j = -1;
7
+ int k, N = 10, j = 1;
8
8
 
9
- double y = 0, t = x;
9
+ double y = x, t = x;
10
10
 
11
- for (k = 0; k <= N; k++) {
11
+ for (k = 0; k < N; k++)
12
12
 
13
- y += t / (j += 2);
13
+ y += (t = -t * x * x) / (j += 2);
14
-
15
- t = -t * x * x;
16
-
17
- }
18
14
 
19
15
  return y;
20
16
 

1

コードの修正

2021/06/30 18:00

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  {
6
6
 
7
- int N = 10, k, j = -1;
7
+ int k, N = 10, j = -1;
8
8
 
9
9
  double y = 0, t = x;
10
10
 
11
- for (int k = 0; k <= N; k++) {
11
+ for (k = 0; k <= N; k++) {
12
12
 
13
13
  y += t / (j += 2);
14
14