1. 程式人生 > >劍指offer---構建乘積數組

劍指offer---構建乘積數組

log 數組 ply div multi clas nbsp blog offer

class Solution 
{
public:
    vector<int> multiply(const vector<int>& A) 
    {
        vector<int> result;
        int size = A.size();
        for (int i = 0; i < size; ++i)
        {
            int chengji=1;
            for (int j = 0; j < size; ++j)
            {
                
if (i!=j ) { chengji = chengji*A[j]; } } result.push_back(chengji); } return result; } };

劍指offer---構建乘積數組