Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Triunghiulare() {
- int n = INT_MIN;
- double a[100][100], b[100], S, x[100];
- cout << "Introd n.\nn = "; cin >> n;
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= n; j++)
- {
- cout << "a[" << i << "][" << j << "] = ";
- cin >> a[i][j];
- }
- }
- for (int i = 1; i <= n; i++)
- {
- cout << "b[" << i << "] = ";
- cin >> b[i];
- }
- for (int i = n; i >= 1; i--)
- {
- S = 0;
- for (int j = i + 1; j <= n; j++)
- {
- S = S + a[i][j] * x[j];
- }
- x[i] = (b[i] - S) / a[i][i];
- }
- cout << endl;
- for (int i = 1; i <= n; i++)
- {
- cout << "x[" << i << "] = " << x[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement