首篇orz代码新鲜出炉!!!

云剪贴板戳我

#include <bits/stdc++.h>
#define fuck_you int
#define shit double
#define LC_txdy main
#define zhy_is_god return
#define wrp for
#define tiger register
#define zty_moshui_txdy srand(time(0));

using namespace std;

fuck_you n;
shit a[110][110];

int LC_txdy(){
    zty_moshui_txdy
    scanf("%d", &n);
    wrp(tiger int i = 1; i <= n; ++ i)
        wrp(tiger int j = 1; j <= n + 1; ++ j) scanf("%lf", &a[i][j]);

    wrp(tiger int i = 1; i <= n; ++ i)
        wrp(tiger int j = 1; j <= n; ++ j){
            fuck_you OOO = rand() % 1001000;
            if(OOO & 1) 
                wrp(tiger int k = 1; k <= n + 1; ++ k) swap(a[i][k], a[j][k]);
        }

    wrp(tiger int i = 1; i <= n; ++ i){
        fuck_you yyl = i;
        wrp(tiger int j = i + 1; j <= n; ++ j) if(fabs(a[j][i]) > fabs(a[yyl][i])) yyl = j;
        wrp(tiger int j = 1; j <= n + 1; ++ j) swap(a[i][j], a[yyl][j]);
        if(!a[yyl][i] && !a[yyl][n + 1]) zhy_is_god cout << 0 << endl, 0;
        if(!a[yyl][i]) zhy_is_god cout << -1 << endl, 0;
        wrp(tiger int j = 1; j <= n; ++ j){
            if(j != i){
                shit yy_l = a[j][i] / a[i][i];
                wrp(tiger int k = i + 1; k <= n + 1; ++ k) a[j][k] -= a[i][k] * yy_l;
            }
        }
    }
    wrp(tiger int i = 1; i <= n; ++ i){
        if(!(a[i][n + 1] / a[i][i])) a[i][n + 1] = 0, a[i][i] = 1;
        printf("x%d=%.2lf\n", i, a[i][n + 1] / a[i][i]);
    }
    zhy_is_god 0;
}
posted @ 2020-11-02 21:23  When_C  阅读(165)  评论(5编辑  收藏  举报