title: C++ Largest number in array. Positive and negative
body: <p>I have a task to print maximum int of matrix second line.</p>
  
  <p>Example input:</p>
  
  <pre><code>3 2 (n, m)
  
  -1 -2 &lt;- 1 line
  
  4 5 &lt;- 2 line
  
  2 6 &lt;- 3 line
  </code></pre>
  
  <p>Max int in second line is 5. My program prints it. But if second line would be -100 -150, it not works. Sure it is because I have max = 0, but I don't know how to use it properly. I'm a student. Thanks in advance.</p>
  
  <p>It is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
    int n, m, max = 0;
    cin &gt;&gt; n &gt;&gt; m;
  
    int matrix[10][10];
  
    for (int i = 0; i &lt; n; i++) {
      for (int j = 0; j &lt; m; j++) {
        cin &gt;&gt; matrix[i][j];
      }
    }
  
    for (int i = 0; i &lt; n; i++) {
      for (int j = 0; j &lt; m; j++) {
        if (matrix[1][j] &gt; max) {
          max = matrix[1][j];
        }
      }
    }
  
    if (max == 0 || n == 1) {
      cout &lt;&lt; "No";
    } else {
      cout &lt;&lt; max;
    }
  }
  </code></pre>
  
  <p>And code works pretty good, unless there are negative numbers in second line</p>