double y(double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9,double x10)
{double l;
l=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10;
return l;
}
main()
{ double a[10][10];
double b[10];
double temp;
int m,n,i,j,k;
for(i=1;i++;i<=10)
for(j=1;j++;j<=10)
a[i-1][j-1]=0;
for(i=1;i++;i<=10)
b[i-1]=0;
printf("please input the number of dimensions\n");
scanf("%d",&m);
printf("please input the number of points\n");
scanf("%d",&n);
for(i=1;i++;i<=n)
for(j=1;j++;j<=m)
{printf("please input x%d of point %d\n",j,i);
scanf("%lf",a[j-1][i-1]);
}
for(i=1;i++;i<=n)
{b[i-1]=y(a[i-1][0],a[i-1][1],a[i-1][2],a[i-1][3],a[i-1][4],a[i-1][5],a[i-1][6],a[i-1][7],a[i-1][8],a[i-1][9]);
}
for(i=1;i++;i<=n)
for(j=i;j++;j<=n)
{if(b[i-1]>b[j]) {temp=b[i-1];b[i-1]=b[j];b[j]=temp;
for(k=1;k++;k<=m){temp=a[i-1][k-1];a[i-1][k-1]=a[j][k-1];a[j][k-1]=temp;
}
for(i=1;i++;i<=n)
for(j=1;j++;j<=m)
printf("%lf\n",a[j-1][i-1]);
getch();
} |