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 func(int a[5][5])
- {
- int i, j, n, max=-300000;
- double s=0;
- for (i=0; i<5; i++)
- {
- for (j=0; j<5; j++)
- {
- s=s+a[i][j];
- }
- if (s>max)
- {
- n=i;
- max=s;
- }
- s=0;
- }
- return (n);
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i, j, a[5][5];
- setlocale (0,"rus");
- for (i=0; i<5;i++)
- {
- for (j=0; j<5;j++)
- {
- a[i][j]=-10+rand()%20;
- }
- }
- cout<<"Матрица 1"<<endl;
- for (i=0; i<5;i++)
- {
- for (j=0; j<5; j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl;
- }
- cout<<endl;
- cout<<"Номер строки с наибольшей суммой элементов= "<<func(a)+1<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement