We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intmax_sum=0;inttemp_sum;for(inti=0;i<4;i++){for(intj=0;j<4;j++){temp_sum=0;// top rowtemp_sum+=arr[i][j];temp_sum+=arr[i][j+1];temp_sum+=arr[i][j+2];//middle temp_sum+=arr[i+1][j+1];//bottom rowtemp_sum+=arr[i+2][j];temp_sum+=arr[i+2][j+1];temp_sum+=arr[i+2][j+2];//if first hourglass, set as maxif(temp_sum>max_sum||i==0&&j==0)max_sum=temp_sum;}}cout<<max_sum;
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
Yup! This is what I used.