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