Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "biblia4.h"
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i=0, j=0,k1,k2;
- int 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;
- func3(a);
- cout<<endl;
- func(a,&k1,&k2);
- cout<<"Сумма положительных элементов= "<<k1<<"\tКол-во отрицательных элементов= "<<k2<<endl;
- cout<<endl;
- cout<<"Кол-во положительных элементов в четных строках матрицы= "<<func2(a)<<endl;
- cout<<endl;
- return 0;
- }
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "biblia4.h"
- using namespace std;
- void func(int a[5][5], int *s, int *n)
- {
- int i=0, j=0; *s=0; *n=0;
- for (i=0; i<5; i++)
- {
- for (j=0; j<5; j++)
- {
- if (a[i][j]>0)
- *s=*s+a[i][j];
- if (a[i][j]<0)
- *n=*n+1;
- }
- }
- }
- double func2(int a[5][5])
- {
- int i, j, p=0;
- for (i=0; i<5; i++)
- {
- for (j=0; j<5; j++)
- {
- if (((i+1)%2==0) && (a[i][j]>0))
- p=p+1;
- }
- }
- return (p);
- }
- void func3 (int a[5][5])
- {
- int i,j;
- for (i=0; i<5;i++)
- {
- for (j=0; j<5; j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl;
- }
- }
- void func(int a[5][5], int *s, int *n);
- double func2(int a[5][5]);
- void func3 (int a[5][5]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement