修改后的程序:

#include "stdio.h" #define N 3 int fun(int a[N][N]) { int i,j,s; s=0; for(i=0;i<N;i++) for(j=i;j<N;j++) // 只计算右上三角 s+=a[i][j]; return s; } int main() { int a[N][N],i,j,s; for(i=0;i<N;i++) for(j=0;j<N;j++) scanf("%d",&a[i][j]); s = fun(a); printf("%d\n",s); return 0; }


原文地址: https://www.cveoy.top/t/topic/fe0H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录