【leetcode】所有奇数长度子数组的和
作者:互联网
int sumOddLengthSubarrays(int* arr, int arrSize){ int i,j,cnt,sum,total=0; for(i=0; i<arrSize; i++) { cnt=0; sum=0; for(j=i; j<arrSize; j++) { cnt++; sum+=arr[j]; if(cnt%2) total+=sum; } } return total; }
标签:arr,奇数,int,sum,sumOddLengthSubarrays,arrSize,数组,cnt,leetcode 来源: https://www.cnblogs.com/ganxiang/p/13942875.html