Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #pragma hdrstop
  2. #pragma argsused
  3.  
  4. #ifdef _WIN32
  5. #include <tchar.h>
  6. #else
  7. typedef char _TCHAR;
  8. #define _tmain main
  9. #endif
  10.  
  11. #include <stdio.h>
  12. #include <iostream>
  13. #include <math.h>
  14. #include <conio.h>
  15. using namespace std;
  16.  
  17. int counter(int *arr, int first, int last, int count);
  18.  
  19. int _tmain() {
  20. int n;
  21. cout << "Enter number of elements of the array: ";
  22. cin >> n;
  23. int* arr = new int[n];
  24. for (int i = 0; i < n; i++) {
  25. cin >> arr[i];
  26. }
  27. cout << "number is: " << counter(arr, 0, n, 0);
  28. delete[]arr;
  29. getch();
  30. return 0;
  31. }
  32.  
  33. int counter(int* arr, int first, int last, int count) {
  34. if (first < (last / 3)) {
  35. double x = arr[first];
  36. first++;
  37. if (cos(x * x) > 0 && x < 0) {
  38. count++;
  39. }
  40. return counter(arr, first, last, count);
  41. }
  42. else if (first < last) {
  43. double x = arr[first];
  44. first++;
  45. if (cos(x * x) > 0 && x < 0) {
  46. count++;
  47. }
  48. return counter(arr, first, last, count);
  49. }
  50. else {
  51. return count;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement