Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i=5, j=5;
- double r=-3000000, k=0;
- double m[5][5]={ {-3.8, 0, 5.3, 4.5, 0.5,},
- {0.2, -1.3, 0, -8.5, 3.5,},
- {-1.1, 1.8, 5.1, -8.2, 0.32,},
- {0, -0.3, 0, -1.28, 0.52,},
- {-0.3, 0.5, 1.8, -7.3, 5.5,} };
- double x[5];
- setlocale(0, "rus");
- cout<<"Матрица 1"<<endl;
- for (i=0; i<5;i++)
- {
- for (j=0; j<5; j++)
- {
- cout<<m[i][j]<<"\t\t ";
- }
- cout<<endl;
- }
- cout<<"Массив №2"<<endl;
- for (i=0; i<5;i++)
- {
- x[i]=m[i][i];
- }
- for (i=0; i<5; i++)
- {
- cout<<x[i]<<" "<<endl;
- if (x[i]>r)
- {
- r=x[i];
- k=i;
- }
- }
- cout<<endl;
- cout<<"Максимальный элемент второго массива= "<<r<<"\t Его номер= "<<k+1<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement