From d04a8462184b92a12d75da49bb8a98fdcc770b0b Mon Sep 17 00:00:00 2001 From: Balentins Date: Tue, 13 Dec 2016 14:41:13 +0100 Subject: [PATCH] ajout du centage attention l'affichage n'est pas au bon endroit --- exiasaver.c | 73 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/exiasaver.c b/exiasaver.c index d19b450..256c53c 100644 --- a/exiasaver.c +++ b/exiasaver.c @@ -1,41 +1,82 @@ #include #include -void afficherTableau(int* tableau); +void afficherTableau(int* tableau1); int main(void) { - int* tableau = malloc(sizeof(int)*80*24); - FILE* fichier = fopen("Pause","r+"); + int* tableau1 = malloc(sizeof(int)*80*24); + FILE* fichier = fopen("image1(2)","r+");//changer nom ---------------------------------------------------- char c = 0; + char v=0; + char b=0; + int L=0; + int C=0; + int col=0; + int lin=0; + int o=0; + while (v!='\0') + { + while (b!='\n') + { + b= fgetc(fichier); + C++; + } + v= fgetc(fichier); + L++; + b=0; + } + col=(80-C)/2; + lin=(80-L)/2; + for (o=80*lin+col+1, o=80*24-(80*lin+col+1), o=o+80) + { + if (o==78-col%80) + { + o=o+C+1; + } + } + + + + + int i=0; int cpt = 0; - while ( cpt < 2) { + while ( cpt < 2) + { c= fgetc(fichier); if (c == '\n') - cpt++; + cpt++; } - do { + + + do + { c= fgetc(fichier); - if(c == '0' || c == '1') { - tableau[i++] = c; + if(c == '0' || c == '1') + { + tableau1[i++] = c; } }while(c != EOF); - afficherTableau(tableau); - free(tableau); - return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */ + afficherTableau(tableau1); + free(tableau1); + return EXIT_SUCCESS; // Equivalent à return 0 sous Windows, permet un code portable } -void afficherTableau(int* tableau) +void afficherTableau(int* tableau1) { int i = 0; int j = 0; - for (i = 0; i < 24; i++) { - for(j = 0; j < 80; j++) { - printf("Tableau[%d][%d] = %d\n", i, j, tableau[i*80+j]); + for (i = 0; i < 24; i++) + { + for(j = 0; j < 80; j++) + { + printf("Tableau1[%d][%d] = %c\n", i, j, tableau1[i*80+j]); + + } } -} +}