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 _tmain(int argc, _TCHAR* argv[])
- {
- int i, j,k=0;
- double min=2;
- double a[5][5]={ {-3.8, 0, 5.3, 4.5, 0.5,},
- {0.2, -1.3, 0, -8.5, 3.5,},
- {-1.1, 1.8, 5.1, -8.2, 0.32,},
- {0, -0.3, 0, -1.28, 0.52,},
- {-0.3, 0.5, 1.8, -7.3, 5.5,} };
- double b[25];
- setlocale(0, "rus");
- cout<<"Матрица 1"<<endl;
- for (i=0; i<5;i++)
- {
- for (j=0; j<5; j++)
- {
- cout<<a[i][j]<<"\t\t ";
- if(a[i][j]>0 && a[i][j]<1)
- {
- b[k]=a[i][j];
- k=k+1;
- }
- }
- cout<<endl;
- }
- cout<<"Массив №2"<<endl;
- for (i=0; i<k; i++)
- {
- cout<<b[i]<<endl;
- if (b[i]<min)
- min=b[i];
- }
- cout<<endl;
- cout<<"Минимальный элемент второго массива= "<<min<<endl;
- return 0;
- }
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- double func(int a[5][5])
- {
- int i, j;
- double p=0;
- for (i=0; i<5; i++)
- {
- for (j=0; j<5; j++)
- {
- p=p+a[i][j];
- }
- }
- return (p);
- }
- void func2 (int a[5][5])
- {
- int i, j;
- for (i=0;i<5;i++)
- {
- for (j=0;j<5;j++)
- {
- if (a[i][j]<0)
- a[i][j]=0;
- }
- }
- }
- 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)<<endl;
- cout<<endl;
- func2(a);
- cout<<"Матрица 2"<<endl;
- for (i=0; i<5;i++)
- {
- for (j=0; j<5; j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement