Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- using namespace std;
- void insert(int *m,int N)
- {
- cout << "Insert element of array" <<endl;
- for (int i=0;i<N;i++) {
- cin >> m[i];
- }
- }
- void print(int m[],int N)
- {
- for (int i=0;i<N;i++)
- cout << m[i] << " ";
- cout << endl;
- // system("pause");
- }
- int sum_array(int m[],int N)
- {
- int sum=0;
- for (int i=0;i<N;i++) {
- sum += m[i];
- }
- return sum;
- }
- int numb_even(int m[],int N)
- {
- cout << "Number of even elements" <<endl;
- int counter=0;
- for (int i=0;i<N;i++){
- if (m[i]%2==0) {
- counter++;
- }
- }
- return counter;
- }
- int count_ab (int m[],int N)
- {
- int counter=0;
- int a,b;
- cout << " Insert a and b,border of interval"<<endl;
- cin >> a;
- cin >> b;
- for (int i=0;i<N;i++)
- {
- if ((m[i]>=a) && (m[i]<=b))
- counter++;
- }return counter;
- }
- bool compare_array(int *m_1,int* m_2,int N)
- {
- for (int i=0;i<N;i++) {
- if (m_1[i] != m_2[i]) {
- return false;
- }
- }
- return true;
- }
- bool positive_array(int m[],int N)
- {
- for (int i=0;i<N;i++)
- if (m[i]<=0)
- return false;
- return true;
- }
- int main()
- {
- int n=10;
- int *m_1 = new int[10];
- int *m_2 = new int[10];
- insert(m_1,n);
- print(m_1,n);
- //cout << sum_array(m_1,n);
- //cout << count_ab(m_1,n);
- //cout << positive_array(m_1,n);
- //cout << numb_even(m_1,n);
- insert(m_2,n);
- print(m_2,n);
- cout << compare_array(m_1,m_2,n);
- delete[]m_1;
- delete[]m_2;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement