题解 | 上三角矩阵判定
上三角矩阵判定
https://www.nowcoder.com/practice/f5a29bacfc514e5a935723857e1245e4
#include <iostream>
using namespace std;
int arr[17][17];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>arr[i][j];
}
}
int no=0;
for(int i=2;i<=n;i++){
for(int j=i-1;j>=1;j--){
if(arr[i][j]!=0){
no++;
}
}
}
if (no==0) {
cout<<"YES"<<endl;
}
else {
cout<<"NO"<<endl;
}
return 0;
}
// 64 位输出请用 printf("%lld")

查看17道真题和解析