Tables 2 dimensions with ranking
This commit is contained in:
+22
-9
@@ -1,28 +1,41 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void afficherTableau(int tableau[24][80]);
|
void afficherTableau(int* tableau);
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
FILE* fichier = NULL;
|
int* tableau = malloc(sizeof(int)*80*24);
|
||||||
fichier=fopen("Pause","r");
|
FILE* fichier = fopen("Pause","r+");
|
||||||
|
char c = 0;
|
||||||
|
int i=0;
|
||||||
|
int cpt = 0;
|
||||||
|
while ( cpt < 2) {
|
||||||
|
c= fgetc(fichier);
|
||||||
|
if (c == '\n')
|
||||||
|
cpt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
c= fgetc(fichier);
|
||||||
|
if(c == '0' || c == '1') {
|
||||||
|
tableau[i++] = c;
|
||||||
|
}
|
||||||
|
}while(c != EOF);
|
||||||
|
|
||||||
int tableau[24][80] = fgetc(fichier);
|
|
||||||
afficherTableau(tableau);
|
afficherTableau(tableau);
|
||||||
|
free(tableau);
|
||||||
return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */
|
return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */
|
||||||
}
|
}
|
||||||
|
|
||||||
void afficherTableau(int tableau[24][80])
|
void afficherTableau(int* tableau)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
for (i = 0; i < 24; i++) {
|
for (i = 0; i < 24; i++) {
|
||||||
for(j = 0; j < 80; j++) {
|
for(j = 0; j < 80; j++) {
|
||||||
printf("Tableau[%d][%d] = %d\n", i, j, tableau[i][j]);
|
printf("Tableau[%d][%d] = %d\n", i, j, tableau[i*80+j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fichier);
|
|
||||||
system("clear");
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user