How about this solution?

From: John (ghaogha_at_fsmail.net)
Date: 12/28/04

  • Next message: Ben Pfaff: "Re: sequence to FULLY test AVL tree implementation???"
    Date: 28 Dec 2004 10:23:07 -0800
    
    

    Hi,
    I am also new with C.I am studying the C in course.
    I performed this solution just as Practice to me.
    I found this Problem among messages from this page on Dec.27.
    The Problem says:

    Declare an array a[10], insert the first element of the array into the
    position specified by a following integer and print the contents.
    output Example:
    1 2 3 4 5 6 7 8 9 10
    4
    2 3 4 1 5 6 7 8 9 10

    I tried .the result showed the error in output and it print the
    different output and not the same as said.
    then what would be the best way to do that?what is the most proper
    alternative way to pay for this problem?
    Thanks for all.

    My Proposed solution is as follows:

    #include <stdio.h>

    int main ()
    {
    int a[10], x;
    int i;

    for(i=0; i<10; i++){
    scanf(" %d", &a[i]);
    }

    putchar('\n');
    for(i=0; i<10; i++){
    printf("%d ",a[i]);
    }
    putchar('\n');

    x = a[0];a[0]= a[1]; a[1]=a[2];
    a[2]=a[3];a[3]=x;

    for(i=0; i<10; i++){
    printf("%d ",a[i]);
    }
      putchar('\n');
      return 0;
    }

    ---
    John
    

  • Next message: Ben Pfaff: "Re: sequence to FULLY test AVL tree implementation???"

    Relevant Pages

    • How about this solution
      ... I am also new with C.I am studying the C in course. ... I performed this solution just as Practice to me. ... Declare an array a, insert the first element of the array into the ... int a, x; ...
      (comp.lang.c)
    • Re: How about this solution?
      ... more practice and advice from experts as I am new with c.. ... Declare an array of length of 10 and read integers ... int a, x; ...
      (comp.programming)
    • Re: C++ Program Help
      ... > everything i wrote on the message board is the whole assignment my pro ... Programming at this stage is mostly practice. ... int main ... Store some numbers in a 5*5 array. ...
      (comp.lang.cpp)
    • (patch for Bash) regex case statement
      ... Following up on my previous patch for regex conditional tests, ... /* Return an array of strings; ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
      (comp.unix.shell)
    • Re: Strategy or Iterator?
      ... It would be possible to write a class that returns the variations ... GNU General Public License for more details. ... protected CombinatoricOperator(Telements, int r) { ... An integer array backing up the original one to keep track of the ...
      (comp.lang.java.programmer)