Advertisement
LabiinfaCibGyti

laba11.17

Dec 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5. int func(int a[5][5])
  6. {  
  7.     int i, j, n, max=-300000;
  8.         double s=0;
  9.     for (i=0; i<5; i++)
  10.         {
  11.             for (j=0; j<5; j++)
  12.             {
  13.                 s=s+a[i][j];
  14.             }
  15.             if (s>max)
  16.             {
  17.                 n=i;
  18.                 max=s;
  19.             }
  20.             s=0;
  21.         }
  22. return (n);
  23. }
  24. int _tmain(int argc, _TCHAR* argv[])
  25. {
  26.     int i, j, a[5][5];
  27.     setlocale (0,"rus");
  28.     for (i=0; i<5;i++)
  29.     {
  30.         for (j=0; j<5;j++)
  31.         {
  32.         a[i][j]=-10+rand()%20;
  33.         }
  34.     }
  35.     cout<<"Матрица 1"<<endl;
  36.         for (i=0; i<5;i++)
  37.         {
  38.             for (j=0; j<5; j++)
  39.             {
  40.                 cout<<a[i][j]<<"\t";
  41.             }
  42.             cout<<endl;
  43.         }
  44.         cout<<endl;
  45.         cout<<"Номер строки с наибольшей суммой элементов= "<<func(a)+1<<endl;
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement