Phoenix_x

Untitled

Nov 29th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. void enterData(int numbers[], int &size);
  6. void multiplicationInRange(int numbers[], int size);
  7. void notZeroSumZeroCount(int numbers[], int size);
  8.  
  9. void main()
  10. {
  11. int numbers[18];
  12. int size = 0;
  13.  
  14. int sumNotZero = 0;
  15. int countZero = 0;
  16.  
  17. while (true)
  18. {
  19. int option;
  20. cout << "Izberi 1 za vavezdane na razmernost i chisla" << endl;
  21. cout << "Izberi 2 za namirane na proizvedenie ot polozitelni chisla v daden interval" << endl;
  22. cout << "Izberi 3 za suma ot nenulevi i broj nulevi." << endl;
  23. cin >> option;
  24.  
  25. switch (option)
  26. {
  27. case 1:
  28. enterData(numbers, size);
  29. break;
  30. case 2:
  31. multiplicationInRange(numbers, size);
  32. break;
  33. case 3:
  34. notZeroSumZeroCount(numbers, size);
  35. break;
  36.  
  37. default:
  38. cout << "Nevaliden vhod" << endl;
  39. }
  40. }
  41. }
  42.  
  43. void enterData(int numbers[], int &size)
  44. {
  45. cout << "Broj chisla: ";
  46. cin >> size;
  47.  
  48. while (size < 0 || size > 18)
  49. {
  50. cout << "Nevaliden razmer!" << endl;
  51. cout << "Vavedi razmer otnovo: ";
  52. cin >> size;
  53. }
  54.  
  55.  
  56. for (int i = 0; i < size; i++)
  57. {
  58. cin >> numbers[i];
  59. }
  60. }
  61.  
  62. void multiplicationInRange(int numbers[], int size)
  63. {
  64. int min;
  65. cout << "Min: ";
  66. cin >> min;
  67.  
  68. int max;
  69. cout << "Max: ";
  70. cin >> max;
  71.  
  72. int multiply = 1;
  73.  
  74. for (int i = 0; i < size; i++)
  75. {
  76. if (numbers[i] >= min && numbers[i] <= max && numbers[i] > 0)
  77. {
  78. multiply *= numbers[i];
  79. }
  80. }
  81.  
  82. cout << "Proizvedenie: " << multiply << endl;
  83. }
  84.  
  85. void notZeroSumZeroCount(int numbers[], int size)
  86. {
  87. int notZero = 0;
  88. int zeroCount = 0;
  89.  
  90. for (int i = 0; i < size; i++)
  91. {
  92. if (numbers != 0)
  93. {
  94. notZero += numbers[i];
  95. }
  96.  
  97. else
  98. {
  99. zeroCount++;
  100. }
  101. }
  102.  
  103. cout << "Broj: " << notZero << endl;
  104. cout << "Suma: " << zeroCount << endl;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment