Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- using namespace std;
- const int N=3;
- const int M=3;
- void OutMatr(double Matr[N][M], double S[N]);
- int main (void)
- {
- setlocale(LC_ALL,"rus");
- double O[N][M]=
- {
- {4.2, 2.5, 5.7},
- {1.2, 5.5, 10.7},
- {3.2, 1.5, 2.7}
- };
- double Sum [N]={0.};
- cout<<"Матрица"<<endl;
- OutMatr(O, Sum);
- cout<<endl<<endl<<"Сумма рядов"<<endl;
- for (int nn=0; nn< N; nn++)
- {
- cout<<Sum[nn]<<"\t\t"<<endl;
- }
- cout<<"Поиск наименьшей суммы"<<endl;
- double lessSum=Sum[0]; int lessRow=0;
- for (int nn=1; nn< N; nn++)
- {
- if (Sum[nn]<lessSum) {lessSum= Sum[nn]; lessRow= nn;}
- }
- for (int mm=0; mm< M; mm++)
- {
- O[lessRow][mm]=3.3;
- }
- cout<<"Новая матрица"<<endl;
- OutMatr(O, Sum);
- system("pause");
- return 0;
- }
- void OutMatr(double Matr[N][M], double S[N])
- {
- for (int nn=0; nn<N; nn++)
- {
- for (int mm=0; mm<M; mm++)
- {
- cout<<Matr[nn][mm]<<"\t"; S[nn]=S[nn] + Matr[nn][mm];
- }
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement