Adak's Profile User Rating: *****

Reputation: 331 Architect
Group:
Contributors
Active Posts:
1,168 (0.94 per day)
Joined:
01-April 11
Profile Views:
6,464
Last Active:
User is offline Jan 04 2014 10:48 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50
Icon   Adak has not set their status

Posts I've Made

  1. In Topic: how the recursion works in the following code segment ?

    Posted 1 Jan 2014

    You take a pie, you cut it in half. You mark one half "low", and the other half "high". You ignore the high half, and cut the "low" half into two pieces.

    Again, you mark the two halves. Again, you ignore the upper half, and cut lower half (now a quarter), into two pieces.

    And keep doing that, always cutting the lower half into two pieces, and ignoring the "high" piece of the pie.

    Finally, the "low" half has nothing left, but you see you have all these "high" halves of various sizes, that still need to be cut up. You take the smallest one, and it becomes the new "low", and gets cut up in the same pattern.

    Eventually, the "low" half of the pie is entirely cut up. Now the second recursive call starts the same process, with the "high" half of the pie.

    It's a beautiful use for recursion. A+ elegant and fast.
  2. In Topic: Checkers longest hit algorithm.

    Posted 31 Dec 2013

    You don't need to return multiple values. Just one move (which might be a struct with "from" and "to" squares, as struct members).

    In chess, you have to extend the depth of the search, as long as you are able to put the opposing king into check - because the next check might give an invaluable fork or even checkmate. In checkers, you could give "jumps" a very high value, and the more jumps in a row, the more the value edges higher.

    They're more into chess, but some have checkers experience:

    Talk Chess:
    http://www.talkchess...forum/index.php
    (Premier chess programming site)

    Never mention "clones", or respond to that word. The programmers there are world class.
  3. In Topic: need help with do while yes/no

    Posted 29 Dec 2013

    One correction:

    for(i=0;i<10;i++);
    
    //just looping, nothing except incrementing i
    printf("%d\n",i);
    
    
    

    What number will be printed after the loop, as the value of i?


    10, not 9. So in an array[10], if you want to print the last value in the array, you should use

    printf("%d \n",array[i-1]);
    
    

    Because array[10] would be out of bounds.

    Reminder:
    1) fflush(stdin) is probably not going to work - not on an input streat. Output only.

    2) Use the space in scanf() before the % in the format string, with chars. That causes char scans to work much better, since they will now skip over whitespace in the input.

    3) Remember than in array[N], the last element is array[N-1].
  4. In Topic: Simplify Source Code

    Posted 29 Dec 2013

    There was just one little thing wrong with the output of your latest code. If the number was NOT present in the table, you did not print that number, as requested by the assignment.

    Everything else worked. (I fixed the problem mentioned above, in the code posted below).

    I suggest you use a consistent and good indentation style, at all times (because it makes debugging code a LOT easier), and be careful to use curly braces around the body of loops, if they have more than one full statement in them.

    Note that stdlib.h and conio.h do not need to be included in your program.
    #include <stdio.h>
    #include<stdlib.h>
    #include<conio.h>
    int main (void){
       int A[10]; 
       int VAL;   
       int POS;  
       int N;     
       int I;    
    
       printf("Enter 10 integers\n");
       N = 10;
       for (I=0; I<N; I++){
          printf("Elément %d : ", I);
          scanf("%d", &A[I]);
       }
       printf("Entrer une nouvelle valeur:\n");
       scanf("%d", &VAL );
       printf("Table : \n");
       for (I=0; I<N; I++)
          printf("%d ", A[I]);
       
       printf("\n");
       POS = -1;
       for (I=0 ; (I<N)&&(POS == -1) ; I++)
          if (A[I] == VAL)
             POS = I;
       
       if (POS == -1)
          printf("The value %d is not in the table\n", VAL);
       else
          printf("Value %d is in the table in position %d. \n", VAL, POS);
        
       return 0;
    }
    
    


    Variables with ALL uppercase letters (like VAL), are normally reserved by the programmer, for use with #define variables.
  5. In Topic: I Don't Understand The Mechanics Of Getting An Array Size In C++?

    Posted 24 Dec 2013

    And OF COURSE, we MUST NOT assume that the OP will know that deleting the * sizeof(int), will give him the number of elements of the array.

    
    size = (stop-start+1);  //size equals the number of elements in the array
    
    size = (stop-start+1) * sizeof(int); //size equals the number of bytes in the array.
    
    
    


    He asked for a clearer explanation, WITHOUT using a template. That's what I gave him.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Computer chess, learning Go!, distributed computing projects.
Years Programming:
17
Programming Languages:
C

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    modi123_1 Icon

    03 Mar 2014 - 07:52
    For future reference: http://www.dreamincode.net/forums/topic/341188-rip-adak-please-join-a-foldathon-if-you-can
  2. Photo

    adityamithal Icon

    23 Nov 2013 - 07:28
    Thanks for all your help
  3. Photo

    raghav.naganathan Icon

    07 Dec 2012 - 01:42
    144...Congrats on the perfect square :)
  4. Photo

    snoopy11 Icon

    29 Nov 2011 - 12:42
    Wow nice job with the for - loops
    Adak...
    That was so elegant...
  5. Photo

    assert(C) Icon

    01 Aug 2011 - 05:25
    THANKS FOR THE HELP
Page 1 of 1