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;
- double func(int a[5][5])
- {
- int i, j;
- double p = 0;
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 5; j++)
- {
- if (a[i][j]%5==0)
- p++;
- }
- }
- 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]%2==0)
- a[i][j]=0;
- }
- }
- }
- int main()
- {
- int i, j, a[5][5];
- setlocale(LC_ALL, "");
- 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 << "Кол-во элементов кратных 5 = " << 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