Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "24bibl.h"
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int a[5][6], i, j;
- setlocale (0,"rus");
- cout<<"Матрица 1"<<endl;
- func3(a);
- cout<<endl;
- cout<<"Сумма положительных элементов= "<<func(a)<<endl;
- cout<<endl;
- cout<<"Измененная матрица"<<endl;
- func2(a);
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl;
- }
- return 0;
- }
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "24bibl.h"
- using namespace std;
- double func(int a[5][6])
- {
- int i, j, p=0;
- for (i=0; i<5; i++)
- {
- for (j=0; j<6; j++)
- {
- if (a[i][j]>0)
- p=p+a[i][j];
- }
- }
- return (p);
- }
- void func2(int a[5][6])
- {
- int i, j;
- for (i=0; i<5; i++)
- {
- for (j=0; j<6; j++)
- {
- if (a[i][j]<0)
- a[i][j]=a[i][j]*3;
- }
- }
- }
- void func3 (int a[5][6])
- {
- int i, j;
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- a[i][j]=-10+rand()%20;
- }
- }
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl;
- }
- }
- double func(int a[5][6]);
- void func2 (int a[5][6]);
- void func3 (int a[5][6]);
Advertisement
Add Comment
Please, Sign In to add comment