Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double func(int arr[]){
- int sum = 0;
- double nepara = 0;
- int k(0);// вказує на к-сть непарних елементів.
- for (int z(0); z < 10; z++){
- if (arr[z] % 2 != 0){ sum += arr[z]; k++; }// сумую непарні елементи
- }
- if (k == 0) exit(0);
- else {
- nepara = sum / k;
- return nepara;
- }
- }
- double input(){
- int const N = 10;
- static int mas[N]{};
- cout << "Enter data to array: " << endl;
- for (int i(0); i < N; i++){
- cout << "Enter [" << i << "]: ";
- cin >> mas[i];
- }
- return func(mas);
- }
- void output(double x){
- cout << "arithmetic mean is: " << x << endl;
- }
- void main(){
- output(input());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement