Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- double arr[100][100];
- cout<<"razmer matric"<<endl;
- cin >> n;
- cout<<"matrica"<<endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j <= n; j++) {
- cin >> arr[i][j];
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j <= n; j++) {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- double temp;
- for (int i = 0; i < n; i++) {
- temp = arr[i][i];
- for (int j = i; j <=n; j++) {
- arr[i][j] /= temp;
- }
- for (int j = i+1; j < n; j++) {
- temp = arr[j][i];
- for (int z = i; z <= n; z++) {
- arr[j][z] -= temp * arr[i][z];
- }
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j <= n; j++) {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- double x[100];
- for (int i = n - 1; i >= 0; i--) {
- x[i] = arr[i][n];
- for (int j = n - 1; j > i; j--) {
- x[i] -= arr[i][j]*x[j];
- }
- }
- for (int i = 0; i < n; i++) {
- cout << x[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement