title: Ordering sequence of numbers in C
body: <p>How would I be able to check the ranking of the numbers in first and second sequence and see if there are ordered the same way? And also is there a way to count the number of elements without having the user input it in?</p>
  
  <p>I want to input a sequence of numbers (the length must be even), and what the program should do it split the sequence in half. And for all the elements in the split sequence they should be arranged in a way that for all i, j, 1&lt;=i, j&lt;=n, a[i]&lt;=a[j] if and only if b[i]&lt;=b[j], where n is the length of a sequence.</p>
  
  <p>Basically it checks the order of the first half of the sequence and checks to see if the order is similar in the second half.</p>
  
  <pre><code>ex: 
  input: 7 5 9 13 12 4 2 25 33 26
  seq1: 7 5 9 13 12
  seq2: 4 2 25 33 26
  Are order equivalent
  </code></pre>
  
  <p>this sequence rank order of 7,5,9,13,12 is 4th,5th,3rd,1st,2nd and the second half also has the same ranking order. Same as if 2,1,5,4 are inputted they are also order equivalent, because seq1 order is 1st largest and 2nd largest same with seq2.</p>
  
  <p>I don't understand the how I would rank the order of the sequences, I was thinking about using bubble sort but then I realized that that it is wrong. I need to split the sequence in half then check the half sequence as they are and see if there the same. </p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>int main(){
      int array[100], n, c, d, swap, first[100], sec[100];
      printf("enter number of elements: ");
      scanf("%d\n", &amp;n)
      printf("enter %d integers:\n", n);
      for(c = 0; c &lt; n; c++)
          scanf("%d", &amp;array[c]);
      //--------------------------------------------------
          printf("\n\n");
          printf("sorted elements in a ascending order\n");
          for(c=0; c&lt;n; c++){ 
              printf("%d ", array[c]);
          }
          printf("\n\n");
      //place first half of array in first array
          for(c = 0; c&lt; (n/2); c++){
              first[c] = array[c]; 
          }
      //place sec half array in sec array
          int a = 0;
          for(c = (n/2); c &lt; (n); c++ ){
              sec[a] = array[c];
              a++;
          }
      //------------------------------------------print arrays 
          printf("\nfirst\n ");
          for(c = 0; c&lt;(n/2); c++){
              printf("%d ", first[c]);
          }
          printf("\nsec\n ");
          for(c = 0; c&lt;(n/2); c++){
              printf("%d ", sec[c]);
          }
          printf("\n\n");
          //bubble sort for first half
          for(c = 0; c &lt;(n-1); c++){
              //c = 3;
              for(d=c; d &lt; n; d++){
                  if (d &gt; c){
                      break;
                  }
                  if(first[d] &gt; first[c]){
                      printf(" before d %d", first[c]);
                      swap = first[c];
                      first[d] = first[c];
                      first[c] = swap;
                      printf(" end d %d", first[d]);
                  }
                  printf(" before d %d", first[c]);
              }
      }
          for(c = 0; c &lt; (n/2); c++ ){
      //----------------------------------------------------print array after sort
              printf("\n\n");
              printf("first array sort %d\n", first[c]);
          }
      return 0;
  }
  </code></pre>