345 lines
9.7 KiB
C
345 lines
9.7 KiB
C
/*fonction qui permet l'ouverture des fichiers en fonction d un chiffre entre 0 et 9 qui correspond a une heure , dizaine d heure, minutes, dizaines minutes ...*/
|
|
FILE* ouverture(int temps) {//----ouverture
|
|
FILE* fichier=NULL;
|
|
switch(temps)
|
|
{
|
|
case 0:
|
|
fichier = fopen("0","r");
|
|
break;
|
|
case 1:
|
|
fichier = fopen("1","r");
|
|
break;
|
|
case 2:
|
|
fichier = fopen("2","r");
|
|
break;
|
|
case 3:
|
|
fichier = fopen("3","r");
|
|
break;
|
|
case 4:
|
|
fichier = fopen("4","r");
|
|
break;
|
|
case 5:
|
|
fichier = fopen("5","r");
|
|
break;
|
|
case 6:
|
|
fichier = fopen("6","r");
|
|
break;
|
|
case 7:
|
|
fichier = fopen("7","r");
|
|
break;
|
|
case 8:
|
|
fichier = fopen("8","r");
|
|
break;
|
|
case 9:
|
|
fichier = fopen("9","r");
|
|
break;
|
|
return fichier;
|
|
}}//------------------------ouverture
|
|
|
|
/*fonction qui permet de cnetrer une image dans u_n tableau */
|
|
int centre(void)
|
|
{
|
|
char v=0;
|
|
int tableau1[1920];
|
|
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);//peut etre pas besoin
|
|
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++)
|
|
{
|
|
v=0;
|
|
v= fgetc(fichier);
|
|
tableau1[o]=v;
|
|
if (o%80==79-col)
|
|
{
|
|
o+=C+1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
void afficherTableauH1(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* HEURE1= NULL;
|
|
HEURE1=ouverture(dizaines_h);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2) {//--------------------------------while
|
|
c= fgetc(HEURE1);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++; }//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(HEURE1);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 0; j < 3; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
|
|
|
|
|
void afficherTableauH2(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* HEURE2= NULL;
|
|
HEURE2=ouverture(unites_h);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2) {//--------------------------------while
|
|
c= fgetc(HEURE2);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++; }//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(HEURE2);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 4; j < 7; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
|
|
|
|
|
|
|
void afficherTableauM1(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* MIN1= NULL;
|
|
MIN1=ouverture(dizaines_m);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2) {//--------------------------------while
|
|
c= fgetc(MIN1);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++; }//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(MIN1);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 10; j < 13; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
|
|
|
|
|
void afficherTableauM2(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* MIN2= NULL;
|
|
MIN2=ouverture(unites_m);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2) {//--------------------------------while
|
|
c= fgetc(MIN2);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++; }//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(MIN2);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 13; j < 16; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherTableauS1(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* SEC1= NULL;
|
|
SEC1=ouverture(dizaines_s);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2) {//--------------------------------while
|
|
c= fgetc(SEC1);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++; }//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(SEC1);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 19; j < 22; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//--------------------------------------------------------------------------------------------------------------------------------------------------------------main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherTableauS2(int* tableau2)
|
|
{//------------------------------------------------------------------------------------void
|
|
|
|
FILE* SEC2= NULL;
|
|
SEC2=ouverture(unites_s);
|
|
char c = 0;
|
|
int i=0;
|
|
int cpt = 0;
|
|
|
|
while ( cpt < 2)
|
|
{//--------------------------------while
|
|
c= fgetc(SEC2);
|
|
if (c == '\n')
|
|
{//------------------------------------------------if
|
|
cpt++;
|
|
}//----------------------------------------------if
|
|
}//-------------------------------------------------while
|
|
|
|
|
|
do {//-------------------------------------------------------------------do/while
|
|
c= fgetc(SEC2);
|
|
if(c == '0' || c == '1') {//--------------------if
|
|
tableau2[i++] = c;
|
|
|
|
}//---------------------------------------------if
|
|
}while(c != EOF);//------------------------------------------------------do/while
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (i = 0; i < 5; i++) {//------------------------------------------------------for
|
|
for(j = 22; j < 26; j++){ //------------for
|
|
|
|
if (tableau2[i*24+j]=='0'){
|
|
printf(" ");
|
|
}
|
|
else {
|
|
printf("%c",987);
|
|
}
|
|
}//------------------------------------------------------------------------------for
|
|
printf("\n");
|
|
|
|
}//------------------------------------------------------------------for
|
|
}//-------------------------------------------------------------------------------
|