题解 | #上三角矩阵判定#

上三角矩阵判定

https://www.nowcoder.com/practice/f5a29bacfc514e5a935723857e1245e4

#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d", &n);//表示方阵的n行n列,1≤n≤10
	int arr[10][10] = { 0 };
	int i = 0;
	int j = 0;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	int count = 0;
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < i; j++)
		{
			if (0 == arr[i][j])
				count++;
		}
	}
	if (count == (n * n - n) / 2)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

全部评论

相关推荐

09-29 15:01
门头沟学院 C++
点赞 评论 收藏
分享
09-18 20:41
百度_Java
要个offer怎么这...:哈哈哈哈哈哈,我也拿了0x10000000个offer,秋招温啦啦啦,好开心
我的秋招日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务