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

靳璐 #42

Open
jinluovo opened this issue Nov 5, 2016 · 0 comments
Open

靳璐 #42

jinluovo opened this issue Nov 5, 2016 · 0 comments

Comments

@jinluovo
Copy link

jinluovo commented Nov 5, 2016

##3乘3的整数矩阵对角线元素之和

#include<stdio.h>
int main()
{
    int a[3][3],i,j,sum=0;
    printf("输入矩阵:\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(i==j||i+j==2)
            {
                sum=sum+a[i][j];
            }
        }
    }
    printf("sum=%d\n",sum);
    return 0;
}
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

1 participant