initial
This commit is contained in:
commit
2802401eee
79 changed files with 2650 additions and 0 deletions
32
1sem/programming basics/z7/20.cpp
Normal file
32
1sem/programming basics/z7/20.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// pb_z7_20.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int count_equal(const int arr[], int len, int x)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i=0; i<len; i++)
|
||||
{
|
||||
count += arr[i] == x;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
int n, x;
|
||||
cout << "n >>>";
|
||||
cin >>n;
|
||||
int *a = new int[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cout << "a[" << i << "] >>>";
|
||||
cin >> a[i];
|
||||
}
|
||||
cout << "x >>>";
|
||||
cin >> x;
|
||||
cout << "count of `" << x << "`: " << count_equal(a, n, x);
|
||||
delete[] a;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue