Create Lecteur 5*3
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void afficherTableau(int* tableau2);
|
||||||
|
int main(void)
|
||||||
|
{//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
||||||
|
|
||||||
|
|
||||||
|
int* tableau2 = malloc(sizeof(int)*03*05);
|
||||||
|
FILE* fichier = fopen("0","r+");
|
||||||
|
char c = 0;
|
||||||
|
int i=0;
|
||||||
|
int cpt = 0;
|
||||||
|
|
||||||
|
while ( cpt < 2) {//--------------------------------while
|
||||||
|
c= fgetc(fichier);
|
||||||
|
if (c == '\n')
|
||||||
|
{//------------------------------------------------if
|
||||||
|
cpt++; }//----------------------------------------------if
|
||||||
|
}//-------------------------------------------------while
|
||||||
|
|
||||||
|
|
||||||
|
do {//-------------------------------------------------------------------do/while
|
||||||
|
c= fgetc(fichier);
|
||||||
|
if(c == '0' || c == '1') {//--------------------if
|
||||||
|
tableau2[i++] = c;
|
||||||
|
|
||||||
|
}//---------------------------------------------if
|
||||||
|
}while(c != EOF);//------------------------------------------------------do/while
|
||||||
|
|
||||||
|
afficherTableau(tableau2);
|
||||||
|
free(tableau2);
|
||||||
|
return EXIT_SUCCESS; /* Equivalent à return 0 sous Windows, permet un code portable */
|
||||||
|
|
||||||
|
}
|
||||||
|
void afficherTableau(int* tableau2)
|
||||||
|
{//------------------------------------------------------------------------------------void
|
||||||
|
|
||||||
|
char c;
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
||||||
|
for(j = 0; j < 3; j++){ //------------for
|
||||||
|
|
||||||
|
if (tableau2[i*03+j]=='0'){
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%c",987);
|
||||||
|
}
|
||||||
|
}//------------------------------------------------------------------------------for
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
}//------------------------------------------------------------------for
|
||||||
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
||||||
Reference in New Issue
Block a user