Can we have a new contest?

This is a discussion on Can we have a new contest? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Please?...

  1. #1
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802

    Can we have a new contest?

    Please?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Sure, come up with a way to get the size of a variable without the sizeof operator. The first person to do it gains the admiration of those who didn't do it first.

    -Prelude
    My best code is written with the delete key.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Deleted due to utter crappiness.

    Note to Self: Have to sleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    Last edited by golfinguy4; 06-30-2002 at 11:55 PM.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    And did you test this at all? Once I fixed the syntax errors, all it does is loop infinitely. Here's a hint: The answer is simpler than you think (one-liner).

    -Prelude
    My best code is written with the delete key.

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    Dual-catfish: do you mean the easy contest?

    my entry:
    Code:
    int main() {
      int i=0;
      long x = 1; //change variable type to any other type
      while (x) {  x<<=1; i++; }
       printf("%d bits",i);
    }
    unfortuneately it doesn't do floating point types.

  6. #6
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    I mean either the easy or the hard, I really depends on what they end up being.

  7. #7
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    i could be persuaded to change the easy if no-one signs up. but the hard one is already locked in stone.

    i'll probably need to hold a poll and restart the easy contest under the new topic if there's a lack of contestants. the two runner-up entries are the bitwise calculator and the slot machine.

    who else agrees with this idea?
    Last edited by ygfperson; 07-01-2002 at 09:13 AM.

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    This is what I had in mind:
    Code:
    #include <stdio.h>
    
    #define SIZEOF(x) (char *)(&x + 1) - (char *)&x
    
    struct test
    {
      int a, b, c, d;
      float f;
    };
    
    int main ( void )
    {
      int i;
      char c;
      float f;
      double d;
      char *a = "This is a test";
      char b[] = "This is a test";
      struct test s;
    
      printf ( "int: %d\nchar: %d\nfloat: %d\ndouble: %d\n"
               "char *: %d\narray: %d\nstruct: %d\n\n",
               SIZEOF(i), SIZEOF(c), SIZEOF(f), SIZEOF(d),
               SIZEOF(a), SIZEOF(b), SIZEOF(s) );
      printf ( "int: %u\nchar: %u\nfloat: %u\ndouble: %u\n"
               "char *: %u\narray: %u\nstruct: %u\n\n",
               sizeof(i), sizeof(c), sizeof(f), sizeof(d),
               sizeof(a), sizeof(b), sizeof(s) );
    
      return 0;
    }
    >who else agrees with this idea?
    Well, if there are no entries, what else can you do?

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 09:34 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  3. WANTED: Contest Master
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-23-2003, 09:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21