fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. const int m_Size = 10;
  4. int main()
  5. {
  6. int matrix[m_Size];
  7. for (int index=0; index<m_Size; ++index)
  8. matrix[index] = round(sin(index+1)*10000);
  9. matrix[3] = 0;
  10. matrix[7] = 0;
  11. std::cout << "Matrix:\n";
  12. for (int index=0; index<m_Size; ++index)
  13. std::cout << matrix[index] << " ";
  14. int summ = 0;
  15. bool find = false;
  16. for (int index=0; index<m_Size; ++index)
  17. {
  18. if (find)
  19. {
  20. if (matrix[index]%2 == -1)
  21. summ += matrix[index];
  22. if (matrix[index] == 0)
  23. break;
  24. }
  25. else
  26. find = matrix[index] == 0;
  27. }
  28. std::cout << "\n\nsumm: " << summ;
  29. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Matrix:
8415 9093 1411 0 -9589 -2794 6570 0 4121 -5440 

summ: -9589