MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / solve

Function solve

codes/cpp/Code_3_06_5.cpp:6–12  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4int N, A[109];
5
6int solve(int l, int r) {
7 if (r - l == 1) return A[l];
8 int m = (l + r) / 2; // 区間 [l, r) の中央で分割する
9 int s1 = solve(l, m); // s1 は A[l]+...+A[m-1] の合計値となる
10 int s2 = solve(m, r); // s2 は A[m]+...+A[r-1] の合計値となる
11 return s1 + s2;
12}
13
14int main() {
15 // 入力

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected