Advertisement
Stoycho_KK

Untitled

Dec 9th, 2021
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. #define rootl 1
  5. #define rootr 2
  6.  
  7. int plusmin(int length, int a[], int n) {
  8.     if (length == 0 && n == 0) return 1;
  9.     else if (length == 0) return 0;
  10.  
  11.     return plusmin(length - 1, a + 1, n - a[0]) +
  12.         plusmin(length - 1, a + 1, n + a[0]);
  13. }
  14.  
  15. //int nodes(int* root) {
  16. //    if(root == NULL) return 0; //can be skipped
  17. //    else if(rootl == NULL && rootr == NULL) return 1; //end case
  18. //
  19. //  else if(rootl != NULL && rootr == NULL) return 1 + nodes(rootl);
  20. //    else if(rootl == NULL && rootr != NULL) return 1 + nodes(rootr);
  21. //    return 1 + nodes(rootl) + nodes(rootr);
  22. //}
  23.  
  24.  
  25. void hasCycle(int arr[], int length) {
  26.     for (int i = 0; i < length; i++) {
  27.        if(arr[i] != -1) {
  28.            //those two can be one var easy:
  29.             int index = i;
  30.             int curr = arr[index];
  31.  
  32.             for (int j = 0; j <= length; j++) {
  33.                 if (curr == -1) {
  34.                     printf("%d %d\n", i, j);
  35.                     j = length + 1; //break
  36.                 }
  37.                 else {
  38.                     arr[index] = -1;
  39.                     index = curr;
  40.                     curr = arr[index];
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
  46.  
  47. int main() {
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement