运行环境:dev c++
#include
using namespace std;
int main (){
float num[4][3];
int i,j;
for (i=0;i<4;i++)
for (j=0;j<3;j++)
cin>>num[i][j];
return 0;
}
完善:从键盘输入n行m列的实数数阵,存入数组num中。
运行环境:dev c++
#include
using namespace std;
int main (){
int i,j,n,m;
cin>>n>>m;
float num[n][m];
for (i=0;i
return 0;
}
交大的学生吧?我也是
double num[4][4];
for (int x=1;x<=4;x++)
for (int y=1;y<=4;y++)
{
cout<<"请输入"<
}
double he = 0.0;
for (int xy=1;xy<=4;xy++)
he = he+num[xy][xy];
cout<<"主对角线上元素之和为:"<
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
#include "stdio.h"
int main()
{
int i,j,djx1,djx2, arry[4][4];
for (i=0;i<4;i++)
{
for (j=0;j<4;j++)
{
scanf("%d",&arry[i][j]);
}
}
djx1 = arry[0][0] + arry[1][1] +arry[2][2] + arry[3][3];
djx2 = arry[0][3] + arry[1][2] +arry[2][1] + arry[3][0];
printf("对角线1:%d \n",djx1);
printf("对角线2:%d \n",djx2);
return 0;
}
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
int sum=0;
for (int i=0;i<3;i++)
sum=sum+a[i][i];