📜  构建前缀数组 cpp - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:47.400000             🧑  作者: Mango

代码示例1
void fillPrefixSum(int arr[], int n, int prefixSum[]) 
{ 
    prefixSum[0] = arr[0]; 
  
    // Adding present element 
    // with previous element 
    for (int i = 1; i < n; i++) 
        prefixSum[i] = prefixSum[i - 1] + arr[i]; 
}