#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main() { int n,i,j; scanf("%d",&n); int a[n][n]; for(i=0;i<n;i++){ for(j=0;j<n;j++){ scanf("%d",&a[i][j]); } } int sum=0; for(i=0;i<n;i++){ for(j=0;j<=i;j++){ sum=sum+a[i][j]; } } printf("%d",sum); } |
Double click to view unformatted code.