Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int stop;
- double a1, a2, a3;
- double y0[3];
- double tablica[1000][3];
- double macierz[3][3];
- double lambdaMax;
- double wektor[3];
- y0[0] = 1; y0[1] = 0; y0[2] = 0;
- cout << "Wprowadz wspolczynnik:" << endl;
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- cout << "a" << i + 1 << j + 1 << " = ";
- cin >> macierz[i][j];
- }
- }
- cout << "Podaj liczbe iteracji: ";
- cin >> stop;
- tablica[0][0]=0.0;
- for(int i=0;i<=stop;i++)
- {
- if(i==0)
- {
- for(int j=0;j<3;j++)
- {
- tablica[i][j]=y0[j];
- }
- }
- else
- {
- for(int j=0;j<3;j++)
- for(int w=0;w<3;w++)
- {
- tablica[i][j] = tablica[i][j] + macierz[w][j]*tablica[i-1][w];
- }
- }
- }
- a1 = tablica[stop][0]/tablica[stop-1][0];
- a2 = tablica[stop][1]/tablica[stop-1][1];
- a3 = tablica[stop][2]/tablica[stop-1][2];
- lambdaMax = (a1+a2+a3)/3;
- double pom = wektor[0];
- for(int i=0;i<3;i++)
- {
- wektor[i] = tablica[stop][i] / pom;
- }
- cout << "Dominujaca wartosc wlasna zadanej macierzy wynosi: " << lambdaMax << endl;
- cout << "Wektor wlasny (zwiazany z dominujaca wartoscia):" << endl;
- for(int i=0;i<3;i++)
- {
- cout << wektor[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement