Message from C, C++ discussions

December 2019

— #howtoask

— 

Try phrasing your question like this:

1. Tell us the problem

2. Tell us what you have done so far.

3. Tell us how you got to this point

4. Paste code in pastebin or something similar

5. Wait for beautiful answers

— Are you asking us to do your homework?

— Indeed

— Chup re

— Hi, anyone knows how to "modify" drand48 to choose your own interval?

— I have another probleeem

— I have a struct with the intergers length and *array

— Typedef struct Better_Array{
int length;
int *array;
} Better_Array;

— Now I'm trying to get the intersection of both arrays

— It's all bits boy

— Better_Array intersect(int *array_a, int length_a, int* array_b, int length_b){
Better_Array ret_arr;

int i, j, k = 0;
while (i < length_a && j < length_b) {
if (array_a[i] < array_b[j]) {
i++;
} else if (array_a[i] > array_b[j]) {
j++;
} else { //array_a[i] == array_b[j])
ret_arr.array[k] = array_a[i];
i++;
j++;
k++;
}
}
return ret_arr;
}

Message permanent page