Search:

Type: Posts; User: rob90

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Thread: Fibonacci

    by rob90
    Replies
    25
    Views
    5,508

    Oh, I didn't notice that he had to find large...

    Oh, I didn't notice that he had to find large fibonacci numbers, i'm sorry, in this case the only solution is to use strings and int arrays to store big numbers, I made an algorithm to find fibonacci...
  2. Thread: Fibonacci

    by rob90
    Replies
    25
    Views
    5,508

    Just use a recursive function

    Just use a recursive function
  3. Replies
    19
    Views
    2,678

    Sorry if I hadn't specified the meaning of the...

    Sorry if I hadn't specified the meaning of the simbol ∑ in my first post, anyway, as many of you have said it means summation, so to calculate the sum of the numbers between 1 and 10 (included)...
  4. Replies
    19
    Views
    2,678

    I was just using Gauss formula in order to...

    I was just using Gauss formula in order to calculate the summation of end without actually adding each value using recursion, I understand it now, thanks tabstop for the help ;)
  5. Replies
    19
    Views
    2,678

    Here: int g(int n) { return n; } int...

    Here:

    int g(int n)
    {
    return n;
    }
    int sum(int (*f)(int), int start, int end)
    {
    if(start==end) return f(start);
    return f(start) + sum(f, start+1, end);
  6. Replies
    19
    Views
    2,678

    Do you mean that I just have to modify the sum...

    Do you mean that I just have to modify the sum function this way?

    int sum(int (*f)(int), int start, int end)
    {
    if(start == end) return f(start);
    printf("%d\n", f(start));
    return sum(g,...
  7. Replies
    19
    Views
    2,678

    Help with pointer to function problem

    Hi everyone, a few months ago my professor gave us a problem which I didn't manage to solve, then I forgot about it but now I found it again and I'm still stuck with it, the problem is:
    given a...
  8. Replies
    3
    Views
    1,144

    You went wrong into the printf function, replace...

    You went wrong into the printf function, replace it with:

    #define PRINTSTR(str) printf("%s", str);
  9. Replies
    5
    Views
    8,034

    I'm not going to read your code, anyway i found...

    I'm not going to read your code, anyway i found that Init's function parameters are incomplete, in fact you can't declare char A[][], int B[][][], char C[][][], while you can declare those arrays as...
  10. Replies
    21
    Views
    1,912

    You really don't need to use strlen(), it was...

    You really don't need to use strlen(), it was just a tip, if you still don't know it you can just do something like:

    i=0;
    while(astring[i] != 'a' && astring[i] != '\0') i++;
    // you just need to...
  11. Replies
    11
    Views
    1,332

    Since you still dont get it I'll tell you, you...

    Since you still dont get it I'll tell you, you put an extra space in the scanf() function, change it with
    scanf("%d", &x);
    Moreover you can simplify you program by doing something like:
    ...
  12. Replies
    11
    Views
    1,332

    scanf( " %d " ,&x ); Check it..

    scanf( " %d " ,&x );

    Check it..
  13. Replies
    21
    Views
    1,912

    You may want to run a loop like: i=0;...

    You may want to run a loop like:


    i=0;
    while(astring[i] != 'a' && astring[i] != '\0') i++;
    then you can just check if i is equal to strlen(astring) you didn't find 'a', else you found it
  14. Replies
    6
    Views
    1,189

    You ought to pass the i variable as a reference...

    You ought to pass the i variable as a reference parameter, so my_funct() should be my_funct(int* i) and then you can access that variable by dereferencing it with the * operator
  15. you just need to declare a structure like ...

    you just need to declare a structure like

    struct node {
    char name[buff];
    struct node* next;
    }
    to sort the list in an alphabetic order you need to use strcmp() and do an insertion sort
  16. Replies
    16
    Views
    2,883

    char teste(char s[]) should be a char* since you...

    char teste(char s[]) should be a char* since you want to return an array
  17. Thread: Boolean algebra

    by rob90
    Replies
    6
    Views
    3,772

    I think that (a . b . c . d . e) should become (e...

    I think that (a . b . c . d . e) should become (e . d . c . b. a) in fact it's just the opposite of the original order relation and it is a duality because it is a "transformation of the structure in...
  18. Replies
    14
    Views
    1,213

    Yes, you should take the number as a string and...

    Yes, you should take the number as a string and then read each element of the array and convert it to an integer to make the sum, but I think that using the modulus is even simpler
  19. Replies
    14
    Views
    1,213

    You can do something like: while(n > 0) sum...

    You can do something like:

    while(n > 0)
    sum += n%10; // sum is 0 at the beginning
    n /= 10;
    using the mod operator you take the last digit of the number and decrement the number dividing it by...
  20. Replies
    9
    Views
    2,952

    If you don't want to use strcmp(), the first...

    If you don't want to use strcmp(), the first thing you have to do is to check if the two strings have the same number of letters(you could use strlen() for this), then iterate over each letter of the...
  21. Replies
    6
    Views
    7,988

    Yes you're right, I have expressed myself wrong...

    Yes you're right, I have expressed myself wrong (I'm not english), what I'm suggesting is to insert each string into a binary search tree which is lg(N) on the average case, instead of making an...
  22. Replies
    6
    Views
    11,635

    the functions you declared are supposed to return...

    the functions you declared are supposed to return an integer while they are actually returning nothing, it's a really simple program why are you using all those if..else statements? you could do it...
  23. Replies
    6
    Views
    7,988

    you must consider that strcmp() returns a value...

    you must consider that strcmp() returns a value greater than 0 if the second string is greater (aphabetically) than the first, 0 if they are equal and a value less than 0 otherwise, plus I suggest to...
  24. Replies
    6
    Views
    1,081

    You can suppose an input that is less than, let's...

    You can suppose an input that is less than, let's say 1000 byte, so you allocate memory for a new char* array with malloc and then fill it with fgets() and at each iterative step you check whether...
  25. Replies
    6
    Views
    1,081

    Why are you using getchar to take the input...

    Why are you using getchar to take the input command? I'd rather store it into a char array[] and then check if array[0] == 'I' && array[1] == 'n' && array[2] == '\0';
Results 1 to 25 of 65
Page 1 of 3 1 2 3