只需要判断 对角线以下的数字即可( i > j )
#include<iostream>
using namespace std;
int main()
{
    int n, i, j;
    int arr[10][10];
    cin >> n;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            cin >> arr[i][j];
    //        有非零则输出“NO”并结束
    for (i = n-1; i >=0; i--)
        for (j = 0; j < i; j++)
            if (arr[i][j] != 0)
            {
                cout << "NO" << endl;
                return 0;
            }
    cout << "YES" << endl;
    return 0;
}