Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

王天锐 #28

Open
wangtianrui opened this issue Oct 30, 2016 · 1 comment
Open

王天锐 #28

wangtianrui opened this issue Oct 30, 2016 · 1 comment

Comments

@wangtianrui
Copy link
Member

矩阵的对角线元素之和

#include<stdio.h>
int main()
{
    int a[100][100];
    int i , j , sum = 0 ;
    printf("输入一个3*3的矩阵:");
    for( i = 0 ; i < 3 ; i ++)
    {
        for( j = 0 ; j < 3 ; j ++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for( i = 0 , j = 2 ; i < 3 ; i ++ , j -- )
    {
        sum = sum + a[i][j] + a[i][i] ;
    }
    sum = sum - a[1][1] ;
    printf("sum=%d\n", sum);
    return 0;
}
@ZhaoLizz
Copy link

爱你哦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants