Thread: Extra Challenge...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    2

    Extra Challenge...

    I will post some challenges here and try to answer them as quickly as possible

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    2
    Write a function checkeven that take in two parameters: an array call numarray containing integers and its size. The function should return the number of even integers in the array. You should initialise some values into the array numarray. Good luck guys!

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Translation: This is a thinly disguised 'do my homework' post.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I will post some challenges here and try to answer them as quickly as possible
    That's a pretty lame attempt. We've seen just about every trick in the book to get other people to do your homework, and this one doesn't even rank in the top ten. It's not even as amusing as the people who pretend to be teachers. I can't give you a very good grade for this.

    Your grade:
    F
    My best code is written with the delete key.

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by agentomen
    Write a function checkeven that take in two parameters: an array call numarray containing integers and its size. The function should return the number of even integers in the array. You should initialise some values into the array numarray. Good luck guys!
    Even if this was actually a challenge you were trying to give us. Most of the people here are programmers for a living. Do you really think this program is a challenge for them? This isn't a challenge for a first year Computer Science student. Please, take this sad attempt for a post to another forum.
    Sent from my iPadŽ

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Translation: This is a thinly disguised 'do my homework' post.
    Another translation - post wacky obfuscated answers which the OP can't possibly hand in as their homework assignment, but which are fun non the less

    Code:
    #include <stdio.h>
    
    int checkeven ( int *numarray, int size ) {
      int j, p = 0, m = ~(~0<<1), c = size;
      while ( p < size ) {
        unsigned int v = 0, w, x;
        for ( j = 0 ; j < 32 && p < size ; j++, p++ ) {
          v ^= ( *numarray++ & m ) << j;
        }
        w = v - ((v >> 1) & 0x55555555);
        x = (w & 0x33333333) + ((w >> 2) & 0x33333333);
        c -= ((((x + (x >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24);
      }
      return c;
    }
    
    int main ( ) {
      int i, test[100];
      for ( i = 0 ; i < 100 ; i++ ) test[i] = i;
      printf( &"%d even numbers found\n"[0], checkeven(test,i) );
      for ( i = 0 ; i < 100 ; i++ ) test[i] = i|1;
      printf( &0["%d even numbers found\n"], checkeven(test,i) );
      for ( i = 0 ; i < 100 ; i++ ) test[i] = i*2;
      printf( "%d even numbers found\n", checkeven(test,i) );
      return 0;
    }

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Haha...

    "This program is exquisite, sir! I'm moving you to AP Computer Science 301 tomorrow"

    "Ehhh... I don't really think that's a good idea, teacher."

    "Nonsense, with your knowledge of programming at your age? You should ace that course easily."
    Sent from my iPadŽ

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by SlyMaelstrom
    Haha...

    "This program is exquisite, sir! I'm moving you to AP Computer Science 301 tomorrow"

    "Ehhh... I don't really think that's a good idea, teacher."

    "Nonsense, with your knowledge of programming at your age? You should ace that course easily."
    ***

    "Hey boss"

    "oh hey valued employee. So you know our company depends on this big project, so how's it going?"

    "About that yeah, seams our corporate firewall is blocking access to internet forums"

    "Get out!"

    BTW it seams Salem was banned? How did tht happen?

  9. #9
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Salem was not banned - otherwise how would he be using his account?

    Nice to see you posting though Salem.

  10. #10
    Registered User
    Join Date
    Nov 2005
    Posts
    31
    out of curiosity, can you give some links of the top ten?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. buffer has extra contents in gtk+ 2.0
    By MK27 in forum Linux Programming
    Replies: 5
    Last Post: 08-04-2008, 11:57 AM
  2. adding extra to char*
    By sujeet1 in forum C Programming
    Replies: 2
    Last Post: 10-17-2007, 12:21 PM
  3. Programming Challenge (for my school)
    By Ezerhorden in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2006, 06:56 AM
  4. Requesting a challenge
    By RealityFusion in forum C++ Programming
    Replies: 8
    Last Post: 08-18-2003, 08:24 PM
  5. From where these two extra bytes came?
    By Juganoo in forum C Programming
    Replies: 4
    Last Post: 12-24-2002, 05:32 PM