Angular, Blockchain, Science とか

Angular, Blockchain, Science全般 の情報を主に書いていきます。

配列の並べ替え

ただの並べ替えです。 reverse です。

#include <stdio.h>

#define maxnumber 10

void run_backwards(int user_array[]);

main()
{
    int number[maxnumber];
    int index;
    
    printf("Give me nine numbers and I\'ll print them backwards \n");
    
    for(index=0; index<maxnumber; ++index)
    {
        printf("Number[%d] = ", index);
        scanf("%d", &number[index]);
    }
    
    printf("Thank you... \n");
    
    run_backwards(number);
}

void run_backwards(int user_array[])
{
    int index;
    printf("\n Here are the numbers oiu entered displayed\n");
    printf("in the reverse order of entry:\n");
    
    for(index=maxnumber-1; index>=0; index--)
        printf("number[%d] = %d\n", index, user_array[index]);
}