首页 > 其他分享 >激光炮(langchao签到题)

激光炮(langchao签到题)

时间:2022-10-22 20:44:51浏览次数:40  
标签:签到 样例 ++ langchao int 激光炮 1000

一道难度不大的题,但这道题之后,发现我敲代码会很复杂,就本身可以几行结束,但会写的很复杂,容易出错,还会比较绕,纯纯自己给自己上难度了!!!

题目:

样例:

 

第一眼感觉还行,非常信心满满的开始敲,敲完之后,试了样例,过了,然后提交,WA!然后很疑惑感觉代码没毛病,检查无果,去找了大神的博客,结果是因为没看到“没有敌人”,下面代码:

#include <iostream>
using namespace std;
int a[1000][1000], b[1000], c[1000];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
b[i] += a[i][j];
c[j] += a[i][j];
}
}
int an = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if(a[i][j] == 0) {
an = max(an, b[i] + c[j]);
}
}
}
cout << an;
return 0;
}

 

标签:签到,样例,++,langchao,int,激光炮,1000
From: https://www.cnblogs.com/shixiaobaiya9/p/16817251.html

相关文章