Skip to content

Instantly share code, notes, and snippets.

@hikilaka
Created February 24, 2017 06:15
Show Gist options
  • Save hikilaka/47e5c5de34bf7bab719d7305d2417348 to your computer and use it in GitHub Desktop.
Save hikilaka/47e5c5de34bf7bab719d7305d2417348 to your computer and use it in GitHub Desktop.
int matrixElementsSum(std::vector<std::vector<int>> matrix) {
int price = 0;
for (int row = 0; row < matrix[0].size(); ++row) {
for (int col = 0; col < matrix.size(); ++col) {
if (matrix[col][row] == 0) {
break;
} else {
price += matrix[col][row];
}
}
}
return price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment