T2: 错误原因:for循环思路错误。 思路:先输入,然后遍历列和行(倒序)并输出。 T3: 错误原因:数组大小开错了,未求对角线最大值。 思路:先输入,再求行列对角线的最大值,最后输出最大值 T4: 错误原因:没做。 思路:```cpp T2: 错误代码: T3: 错误代码: #include <iostream> using namespace std;
int a[105][105];
int main(){ int n, maxn = 0; cin >> n; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> a[i][j]; } } for(int i = 0; i < n; i++){ int sum = 0; for(int j = 0; j < n; j++){ sum += a[i][j]; } maxn = max(maxn, sum); } cout << maxn; return 0; } 错误代码:没做 先输入,再把旋转,翻转,比较做成函数,再处理,最后输出。