CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 07:25:11 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=48672d055e5ca7f0db31b11653de0a27045ef1a95374b2431d332a8fceb3cc57a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22XY1n5IBqbbre0wu32bFk_7cgDYmxLKPf%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d4dca278751712-BLR
gauss - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://themis.lo14.wroc.pl/2ITN2015/GAUSS1
- #include <bits/stdc++.h>
- using namespace std;
- vector < vector <long double> >T;
- vector <long double> x;
- int n;
- void readMatrix() {
- long double a;
- scanf("%d ", &n);
- T.resize(0);
- x.resize(0);
- T.resize(n);
- x.resize(n);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j <= n; j++) {
- scanf("%Lf", &a);
- T[i].push_back(a);
- }
- }
- }
- //void printMatrix(int a) {
- // printf("#=== %d\n", a);
- // for (int i = 0; i < n; i++) {
- // for (int j = 0; j <= n; j++) {
- // printf("%lf ", T[i][j]);
- // }
- // printf("\n");
- // }
- // printf("\n");
- //}
- void printRoots() {
- x[n - 1] = T[n - 1][n] / T[n - 1][n - 1]; //dodaje Xn
- for (int i = n - 2; i >= 0; i--) {
- long double r = T[i][n] * (-1); //to co po znaku równości
- for (int j = n - 1; j > i; j--)
- r += T[i][j] * x[j];
- x[i] = r / T[i][i];
- x[i] *= -1;
- }
- for (int i = 0; i < n; i++) {
- printf("%.6Lf ", x[i]);
- }
- printf("\n");
- }
- bool thxrafzadbg(int k) {
- for (int s = k + 1; s < n; s++) {
- if (abs(T[k][k]) < abs(T[s][k]))
- swap(T[s], T[k]);
- }
- //printMatrix(k);
- if (abs(T[k][k]) <= 0.000001) return 0;
- return 1;
- }
- void f() {
- readMatrix();
- for (int k = 0; k < n; k++) { // main loop
- ///printMatrix();
- if (!thxrafzadbg(k)) {
- printf("ZA TRUDNE\n");
- return;
- }
- for (int i = k + 1; i < n; i++) {
- long double multiplier = T[i][k] / T[k][k];
- for (int j = k; j <= n; j++) {
- T[i][j] -= T[k][j] * multiplier;
- }
- }
- }
- printRoots();
- }
- int main() {
- int testy;
- scanf("%d", &testy);
- while (testy--) f();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 8 sec ago | 0.10 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 10 sec ago | 0.10 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 20 sec ago | 0.10 KB
-
⭐⭐⭐Exchange Exploit T 3⭐⭐
Java | 31 sec ago | 0.10 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 35 sec ago | 0.10 KB
-
⭐⭐⭐Exchange Exploit⭐⭐
Java | 42 sec ago | 0.10 KB
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 47 sec ago | 0.10 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 54 sec ago | 0.10 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand