Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #define rootl 1
- #define rootr 2
- int plusmin(int length, int a[], int n) {
- if (length == 0 && n == 0) return 1;
- else if (length == 0) return 0;
- return plusmin(length - 1, a + 1, n - a[0]) +
- plusmin(length - 1, a + 1, n + a[0]);
- }
- //int nodes(int* root) {
- // if(root == NULL) return 0; //can be skipped
- // else if(rootl == NULL && rootr == NULL) return 1; //end case
- //
- // else if(rootl != NULL && rootr == NULL) return 1 + nodes(rootl);
- // else if(rootl == NULL && rootr != NULL) return 1 + nodes(rootr);
- // return 1 + nodes(rootl) + nodes(rootr);
- //}
- void hasCycle(int arr[], int length) {
- for (int i = 0; i < length; i++) {
- if(arr[i] != -1) {
- //those two can be one var easy:
- int index = i;
- int curr = arr[index];
- for (int j = 0; j <= length; j++) {
- if (curr == -1) {
- printf("%d %d\n", i, j);
- j = length + 1; //break
- }
- else {
- arr[index] = -1;
- index = curr;
- curr = arr[index];
- }
- }
- }
- }
- }
- int main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement