判断条件改成i + j <= 10 && i > j更简洁
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double a[12][12], s = 0;
char t;
cin >> t;
int c = 0;
for (int i = 0; i < 12; i ++ )
{
for(int j = 0; j < 12; j ++)
{
cin >> a[i][j];
if ( i <= 5 && j <= i - 1 || i > 5 && i + j <= 10)//(i+j)<=10&&i>j
{
c ++;
s += a[i][j];
}
}
}
printf("%.1lf", t == 'S'? s: s / c);
return 0;
}