很高深
#include<cstdio> #include<cstring> int n,i,j,k; double a[502][502]; double x[502],t; int main() { freopen("shopping.in","r",stdin); freopen("shopping.out","w",stdout); scanf("%d\n",&n); for (i=1;i<=n;i++) for (j=1;j<=n+1;j++) { int x; scanf("%d",&x); a[i][j]=x; } for (i=1;i<=n-1;i++) for (j=i+1;j<=n;j++) { t=a[j][i]/a[i][i]; a[j][i]=0; for (k=i+1;k<=n+1;k++) a[j][k]=a[j][k]-(t*a[i][k]); } x[n]=(a[n][n+1]/a[n][n]); for (i=n-1;i>0;i--) { t=a[i][n+1]; for (j=n;j>=i+1;j--) t-=x[j]*a[i][j]; x[i]=t/a[i][i]; } for (i=1;i<=n;i++) printf("%.f\n",x[i]); return 0; }