Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- void enterData(int numbers[], int &size);
- void multiplicationInRange(int numbers[], int size);
- void notZeroSumZeroCount(int numbers[], int size);
- void main()
- {
- int numbers[18];
- int size = 0;
- int sumNotZero = 0;
- int countZero = 0;
- while (true)
- {
- int option;
- cout << "Izberi 1 za vavezdane na razmernost i chisla" << endl;
- cout << "Izberi 2 za namirane na proizvedenie ot polozitelni chisla v daden interval" << endl;
- cout << "Izberi 3 za suma ot nenulevi i broj nulevi." << endl;
- cin >> option;
- switch (option)
- {
- case 1:
- enterData(numbers, size);
- break;
- case 2:
- multiplicationInRange(numbers, size);
- break;
- case 3:
- notZeroSumZeroCount(numbers, size);
- break;
- default:
- cout << "Nevaliden vhod" << endl;
- }
- }
- }
- void enterData(int numbers[], int &size)
- {
- cout << "Broj chisla: ";
- cin >> size;
- while (size < 0 || size > 18)
- {
- cout << "Nevaliden razmer!" << endl;
- cout << "Vavedi razmer otnovo: ";
- cin >> size;
- }
- for (int i = 0; i < size; i++)
- {
- cin >> numbers[i];
- }
- }
- void multiplicationInRange(int numbers[], int size)
- {
- int min;
- cout << "Min: ";
- cin >> min;
- int max;
- cout << "Max: ";
- cin >> max;
- int multiply = 1;
- for (int i = 0; i < size; i++)
- {
- if (numbers[i] >= min && numbers[i] <= max && numbers[i] > 0)
- {
- multiply *= numbers[i];
- }
- }
- cout << "Proizvedenie: " << multiply << endl;
- }
- void notZeroSumZeroCount(int numbers[], int size)
- {
- int notZero = 0;
- int zeroCount = 0;
- for (int i = 0; i < size; i++)
- {
- if (numbers != 0)
- {
- notZero += numbers[i];
- }
- else
- {
- zeroCount++;
- }
- }
- cout << "Broj: " << notZero << endl;
- cout << "Suma: " << zeroCount << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment