Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- main()
- {
- FILE *fdat, *fres;
- fdat=fopen("cdepi081.res","r");
- fres=fopen("cdepi082.res","w");
- int i, numDossard[31], temps[31][6][4];
- int hTot[31], minTot[31], secTot[31], j, nb;
- char nom[31][14];
- char nat[31][4];
- int ind[31];
- int place[31];
- void classement (int , int [][6][4], int[], int, int[] );
- i = 1;
- fscanf (fdat,"%2d", &numDossard[i]);
- while ( !feof(fdat) )
- {
- fscanf (fdat,"%13s", &nom[i]);
- fscanf (fdat,"%3s", &nat[i]);
- for ( j = 1 ; j <= 5 ; j++ )
- {
- fscanf ( fdat,"%1dh%2dm%2ds", &temps[i][j][1], &temps[i][j][2], &temps[i][j][3] );
- }
- fscanf ( fdat,"%2dh%2dm%2ds", &hTot[i], &minTot[i], &secTot[i] );
- i++;
- fscanf (fdat,"%2d", &numDossard[i]);
- }
- nb = i - 1;
- printf ("%2d", nb);
- for ( i = 1 ; i <= nb ; i++ )
- {
- ind[i] = i;
- place[i] = i;
- }
- int k = 1;
- //classement (nb, temps, ind, 1);
- for ( j = 1 ; j <= 5 ; j++ )
- {
- classement (nb, temps, ind, j, place);
- fprintf (fres,"\nClassement de l'étape n°%1d", j);
- fprintf (fres,"\n-------------------------\n\n");
- for ( i = 1 ; i <= nb ; i++ )
- {
- }
- }
- }
- void classement (int nb, int temps[][6][4], int ind[], int e, int place[])
- {
- int i,j;
- for ( i = 1 ; i < nb ; i++ )
- {
- for ( j = i+1 ; j <= nb ; j++ )
- {
- if ( temps[ind[i]][e][1] > temps[ind[j]][e][1] )
- {
- ind[0]=ind[i];
- ind[i]=ind[j];
- ind[j]=ind[0];
- }
- else if ( temps[ind[i]][e][1] == temps[ind[j]][e][1] )
- {
- if ( temps[ind[i]][e][2] > temps[ind[j]][e][2] )
- {
- ind[0]=ind[i];
- ind[i]=ind[j];
- ind[j]=ind[0];
- }
- }
- else if ( temps[ind[i]][e][2] == temps[ind[j]][e][2] )
- {
- if ( temps[ind[i]][e][3] > temps[ind[j]][e][3] )
- {
- ind[0]=ind[i];
- ind[i]=ind[j];
- ind[j]=ind[0];
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement