Dans une 1ère routine, la principale avec une forme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
#include <vcl.h>
#pragma hdrstop
 
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
je voudrais y inclure une deuxième routine qui fera la saisie
de plusieurs valeurs ( a ranger dans un tableau )

et qui affichera ce tableau
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
// une fonction ordonnerTableau qui classe les valeurs d'un tableau dans l'ordre décroissant. Ainsi, un tableau qui vaut {15, 81, 22, 13} doit à la fin de la fonction valoir {81, 22, 16, 13} !
 
#include <stdio.h> 
 
void ordonnerTableau(long tableau[], long tailleTableau); 
 
int main(int argc, char *argv[]) 
{ 
    long tab[4] = {15,81,22,13}; 
    int i=0; 
    ordonnerTableau(tab,4); 
    for(i=0; i<4; i++) 
    { 
        printf("%ld\n",tab[i]); 
    } 
    return 0; 
} 
void ordonnerTableau(long tableau[], long tailleTableau) 
{ 
    long i,t,k=0; 
    for(t = 1; t < tailleTableau; t++) 
    { 
        for(i=0; i < tailleTableau - 1; i++) 
        { 
            if(tableau[i] < tableau[i+1]) 
            { 
                k= tableau[i] - tableau[i+1]; 
                tableau[i] -= k; 
                tableau[i+1] += k; 
            } 
        } 
    } 
}