Thread: Even / Odd Issues

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    You could add two integers being an evencount and an oddcount to increment when you save into the respective arrays.

    Code:
    int evenTemp[N/2];
      int oddTemp[(N-1)/2];
      int evencount = 0;
      int oddcount = 0;
      char tempOdd;
         
      for(i=0; i < N-1 ; i++)
      {
        if(odd[i]%2 == 0) /* if even integer*/
        {
          evenTemp[evencount] = odd[i]; /*store even numbers temporary */
          evencount++;
        }
        else
        {
          oddTemp[oddcount]= odd[i]; /*store odd numbers temporary */
          oddcount++;
        }
      }
    You still need to look at why your two arrays add up to 8 in size but your final array needs 9 numbers
    Last edited by Lesshardtofind; 12-07-2012 at 12:08 AM.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having issues with my FFT
    By DavidP in forum C++ Programming
    Replies: 8
    Last Post: 04-05-2010, 01:27 PM
  2. issues
    By OrAnGeWorX in forum C Programming
    Replies: 35
    Last Post: 11-19-2008, 12:18 AM
  3. Issues
    By Tamandt in forum C++ Programming
    Replies: 22
    Last Post: 09-10-2004, 11:42 AM
  4. PC issues....
    By RoD in forum Tech Board
    Replies: 10
    Last Post: 03-11-2004, 05:44 PM
  5. .EXE Issues
    By SpankyTheWalrus in forum Windows Programming
    Replies: 4
    Last Post: 03-07-2004, 12:48 PM