indian a écrit : Ah? vous possédez la version des Évangiles en langage francophone ou C++?
oui voir là ci-dessous-> il y pas la place pour tout mettre on est limité à 60000 caracteres
maths15-07-2016-19h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#ifndef SSC
#define SSC "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-+=*.^()[]{}<>|!?,;:~#@§/&$ "
#endif
#ifndef TAILLE_SSC
#define TAILLE_SSC 91
#endif
#ifndef TAILLE_MATH
#define TAILLE_MATH 1000
#endif
#ifndef TAILLE_TEXTE
#define TAILLE_TEXTE 1000
#endif
#ifndef INITIALISATION
#define INITIALISATION time_t t=time(NULL);\
char*c_time=NULL;\
c_time=ctime(&t);\
printf("date %s",c_time);\
printf("time compilation %s\n",__TIME__);\
printf("INT_MIN: %d\n"\
"INT_MAX: %d\n",INT_MIN,INT_MAX);\
printf("LLONG_MIN: %I64d\n"\
"LLONG_MAX: %I64d\n",LLONG_MIN,LLONG_MAX);\
printf("char: %d octets\n"\
"int: %d octets\n"\
"long long int: %d octets\n"\
"double: %d octets\n",sizeof(char),sizeof(int),sizeof(long long),sizeof(double));\
printf("__________________________________________\n");\
int texte;\
int *texte_=&texte;\
long long int taille;\
long long int *taille_=&taille;\
int type;\
int *type_=&type;\
int scan;\
int *scan_=&scan;\
int buffer;\
int *buffer_=&buffer;\
int saisie;\
int *saisie_=&saisie;\
int math;\
int *math_=&math;\
long long int signe1;\
long long int *signe1_=&signe1;\
long long int signe2;\
long long int *signe2_=&signe2;\
long long int point1;\
long long int *point1_=&point1;\
long long int point2;\
long long int *point2_=&point2;\
int i;\
int *i_=&i;\
int signe;\
int *signe_=&signe;\
int point;\
int *point_=&point;\
int niveau;\
int *niveau_=&niveau;\
int categorie;\
int *categorie_=&categorie;\
long long int SEQUENCE[8];
#endif
void f_math(char*,int*,int*,long long int*,long long int*,long long int*,long long int*,long long int*,long long int*,int*,int*,int*,int*,int*);
void scan_math(char*,int*,long long int*,int*,int*,int*,int*,long long int*,long long int*,long long int*,long long int*,long long int*,int*,int*,int*,int*,int*);
void f_texte(char*,int*,long long int*,int*);
void scan_texte(char*,int*,long long int*,int*,int*,int*,int*);
void f_insert(char*,char*,long long int);
void f_inv(char*,int*,long long int*);
void f_unit(char*,long long int,int*,long long int*);
void f_blank(char*,long long int,long long int,int*,long long int*);
void f_space(char*,int*,long long int*);
void f_scan(char*,long long int*,int*,int*,int*,int*);
void f_scanf(char*,int*,int*);
void f_size(char*,int*,long long int*);
void f_buffer(void);
int f_egal(char*,char*);
char* f_mot(char*,char*);
long long int f_lcode(char*,long long int);
int f_code(char*,long long int);
double f_time(void);
double f_double(long long int*);
void f_long(double ,long long int*);
long long int f_intlong(int);
int main(int argc,char*argv[])
{
INITIALISATION
char *n_nombre=NULL;
n_nombre=malloc(TAILLE_MATH*sizeof(char));
if (n_nombre==NULL)
{
printf("echec allocation");
exit(0);
}
printf("saisir nombre\n");
scan_math(n_nombre,math_,taille_,saisie_,buffer_,scan_,type_,SEQUENCE,signe1_,signe2_,point1_,point2_,i_,signe_,point_,niveau_,categorie_);
f_size(n_nombre,type_,taille_);
printf("taille n_nombre=%I64d\nn_nombre=%s\n",taille,n_nombre);
if (math)
{
printf("saisie nombre valide\ncategorie=%d\n",categorie);
printf("i=%d\n"
"signe=%d\n"
"signe1=%I64d\n"
"signe2=%I64d\n"
"point=%d\n"
"point1=%I64d\n"
"point2=%I64d\n"
"niveau=%d\n"
"SEQUENCE[0]=%I64d\n"
"SEQUENCE[1]=%I64d\n"
"SEQUENCE[2]=%I64d\n"
"SEQUENCE[3]=%I64d\n"
"SEQUENCE[4]=%I64d\n"
"SEQUENCE[5]=%I64d\n"
"SEQUENCE[6]=%I64d\n"
"SEQUENCE[7]=%I64d\n",i,signe,signe1,signe2,point,point1,point2,niveau,SEQUENCE[0],SEQUENCE[1],SEQUENCE[2],SEQUENCE[3],SEQUENCE[4],SEQUENCE[5],SEQUENCE[6],SEQUENCE[7]);
}
if (!math)
{
printf("saisie nombre invalide\ncategorie=%d\n",categorie);
}
char *c_texte=NULL;
c_texte=malloc(TAILLE_TEXTE*sizeof(char));
if (c_texte==NULL)
{
printf("echec allocation");
exit(0);
}
printf("saisir texte\n");
scan_texte(c_texte,texte_,taille_,saisie_,buffer_,scan_,type_);
f_size(c_texte,type_,taille_);
printf("taille c_texte=%I64d\nc_texte=\n%s\n",taille,c_texte);
if (texte)
{
printf("saisie texte valide\n");
}
if (!texte)
{
printf("saisie texte invalide\n");
}
free(c_texte);
free(n_nombre);
return 0;
}
void scan_texte(char*c_ssc,int*texte_,long long int*taille_,int*saisie_,int*buffer_,int*scan_,int*type_)
{
*texte_=0,*scan_=0;
f_scan(c_ssc,taille_,saisie_,buffer_,scan_,type_);
if (*saisie_==1&&*buffer_==0&&*type_==1&&*taille_>0)
{
f_texte(c_ssc,texte_,taille_,type_);
}
}
void f_texte(char*c_ssc,int*texte_,long long int*taille_,int*type_)
{
*texte_=1;
f_size(c_ssc,type_,taille_);
if (*taille_>0)
{
long long int compteur;
int compteur0;
for (compteur=0;compteur<*taille_;compteur++)
{
for (compteur0=0;compteur0<TAILLE_SSC;compteur0++)
{
if (c_ssc[compteur]==SSC[compteur0])
{
break;
}
else if(compteur0==(TAILLE_SSC-1)&&c_ssc[compteur]!=SSC[compteur0])
{
*texte_=0;
break;
}
}
if (!*texte_)
{
break;
}
}
}
}
void scan_math(char*n_math,int*math_,long long int*taille_,int*saisie_,int*buffer_,int*scan_,int*type_,long long int*SEQUENCE,long long int*signe1_,long long int*signe2_,long long int*point1_,long long int*point2_,int*i_,int*signe_,int*point_,int*niveau_,int*categorie_)
{
*math_=0,*categorie_=0,*scan_=1;
f_scan(n_math,taille_,saisie_,buffer_,scan_,type_);
if (*saisie_==1&&*buffer_==0&&*type_==1&&*taille_>0)
{
f_math(n_math,math_,type_,taille_,SEQUENCE,signe1_,signe2_,point1_,point2_,i_,signe_,point_,niveau_,categorie_);
}
}
void f_scanf(char*x,int*scan_,int*saisie_)
{
switch (*scan_)
{
case 0:
/* attention TAILLE_TEXTE>=100 */
if(scanf("%100[^\n]",x)==1)
{
*saisie_=1;
}
else
{
*saisie_=0;
}
break;
case 1:
/* attention TAILLE_MATH>=100 */
if(scanf("%100[ 0123456789-+.i]",x)==1)
{
*saisie_=1;
}
else
{
*saisie_=0;
}
break;
default:
break;
}
}
void f_buffer(void)
{
int c;
while ((c=getchar())!=EOF&&c!='\n');
}
double f_time(void)
{
double tim;
time_t t=time(NULL);
char*c_time=NULL;
c_time=ctime(&t);
double *mem=NULL;
mem=malloc(5*sizeof(double));
if (mem==NULL)
{
exit(0);
}
mem[0]=fabs(f_code(c_time,17))*10.0+fabs(f_code(c_time,18));
mem[1]=fabs(f_code(c_time,14))*10.0+fabs(f_code(c_time,15));
mem[2]=fabs(f_code(c_time,11))*10.0+fabs(f_code(c_time,12));
mem[3]=fabs(f_code(c_time,8))*10.0+fabs(f_code(c_time,9));
mem[4]=1.0;
if (c_time[4]=='F')
{
mem[4]=2.0;
}
if (c_time[4]=='S')
{
mem[4]=9.0;
}
if (c_time[4]=='O')
{
mem[4]=10.0;
}
if (c_time[4]=='N')
{
mem[4]=11.0;
}
if (c_time[4]=='D')
{
mem[4]=12.0;
}
if (c_time[4]=='A'&&c_time[5]=='p')
{
mem[4]=4.0;
}
if (c_time[4]=='A'&&c_time[5]=='u')
{
mem[4]=8.0;
}
if (c_time[4]=='M'&&c_time[6]=='r')
{
mem[4]=3.0;
}
if (c_time[4]=='M'&&c_time[6]=='y')
{
mem[4]=5.0;
}
if (c_time[4]=='J'&&c_time[5]=='a'&&c_time[6]=='n')
{
mem[4]=1.0;
}
if (c_time[4]=='J'&&c_time[5]=='u'&&c_time[6]=='n')
{
mem[4]=6.0;
}
if (c_time[4]=='J'&&c_time[5]=='u'&&c_time[6]=='l')
{
mem[4]=7.0;
}
tim=(mem[0]*0.0166666666669)+(mem[1]*0.0002777777779)+(mem[2]*0.0000115740749)+(mem[3]*0.0000003733579)+(mem[4]*0.0000000311139);
free(mem);
if (tim>=0.999999999999)
{
tim=0.999999999999;
}
if (tim<=0.000000000001)
{
tim=0.000000000001;
}
return tim;
}
long long int f_lcode(char*x,long long int z)
{
long long int y=91;
int compteur;
for (compteur=0;compteur<91;compteur++)
{
if (x[z]==SSC[compteur])
{
y=compteur;
}
}
return y;
}
int f_code(char*x,long long int z)
{
int y=91;
int compteur;
for (compteur=0;compteur<91;compteur++)
{
if (x[z]==SSC[compteur])
{
y=compteur;
}
}
return y;
}
void f_size(char*x,int*type_,long long int*taille_)
{
if (x==NULL)
{
*taille_=0;
*type_=0;
}
else
{
*taille_=strlen(x);
*type_=1;
}
}
void f_long(double x,long long int*lg)
{
double dec=x+0.0000000000009;
int chiffre,divise,compteur,scompteur;
long long int*mema=NULL;
mema=malloc(3*sizeof(long long int));
if (mema==NULL)
{
exit(0);
}
int *memb=NULL;
memb=malloc(4*sizeof(int));
if (memb==NULL)
{
exit(0);
}
for (compteur=0;compteur<4;compteur++)
{
dec*=1000;
memb[compteur]=abs(floor(dec));
dec=dec-floor(dec);
divise=100;
for (scompteur=0;scompteur<3;scompteur++)
{
chiffre=memb[compteur]/divise;
switch (chiffre)
{
case 0:
mema[scompteur]=0;
break;
case 1:
mema[scompteur]=1;
break;
case 2:
mema[scompteur]=2;
break;
case 3:
mema[scompteur]=3;
break;
case 4:
mema[scompteur]=4;
break;
case 5:
mema[scompteur]=5;
break;
case 6:
mema[scompteur]=6;
break;
case 7:
mema[scompteur]=7;
break;
case 8:
mema[scompteur]=8;
break;
case 9:
mema[scompteur]=9;
break;
default :
exit(0);
}
memb[compteur]=memb[compteur]-(chiffre*divise);
divise/=10;
}
lg[compteur]=mema[0]*100+mema[1]*10+mema[2];
}
free(mema);
free(memb);
if (lg[3]<=0)
{
lg[3]=0;
}
if (lg[3]>=999)
{
lg[3]=999;
}
}
double f_double(long long int*lg)
{
double dec=0;
int compteur,scompteur;
long long int chiffre,divise,deci;
double *mema=NULL;
mema=malloc(3*sizeof(double));
if (mema==NULL)
{
exit(0);
}
double *memb=NULL;
memb=malloc(4*sizeof(double));
if (memb==NULL)
{
exit(0);
}
for (compteur=0;compteur<4;compteur++)
{
divise=100;
deci=lg[compteur];
for (scompteur=0;scompteur<3;scompteur++)
{
chiffre=deci/divise;
deci=deci-(chiffre*divise);
switch (chiffre)
{
case 0:
mema[scompteur]=0.0;
break;
case 1:
mema[scompteur]=1.0;
break;
case 2:
mema[scompteur]=2.0;
break;
case 3:
mema[scompteur]=3.0;
break;
case 4:
mema[scompteur]=4.0;
break;
case 5:
mema[scompteur]=5.0;
break;
case 6:
mema[scompteur]=6.0;
break;
case 7:
mema[scompteur]=7.0;
break;
case 8:
mema[scompteur]=8.0;
break;
case 9:
mema[scompteur]=9.0;
break;
default :
exit(0);
}
divise/=10;
}
memb[compteur]=(mema[0]/10.0)+(mema[1]/100.0)+(mema[2]/1000.0);
}
dec=memb[0]+(memb[1]/1000.0)+(memb[2]/1000000.0)+(memb[3]/1000000000.0);
free(mema);
free(memb);
return dec;
}
void f_scan(char*x,long long int*taille_,int*saisie_,int*buffer_,int*scan_,int*type_)
{
f_scanf(x,scan_,saisie_);
char c;
if ((c=getchar())!='\n')
{
*buffer_=1;
f_buffer();
}
else
{
*buffer_=0;
}
f_size(x,type_,taille_);
}
int f_egal(char*x,char*y)
{
int egal=0;
if (x!=NULL && y!=NULL)
{
long long int longx=strlen(x),longy=strlen(y);
if (longx==longy&&longx>0)
{
egal=1;
long long int compteur;
for (compteur=0;compteur<longx;compteur++)
{
if (x[compteur]!=y[compteur])
{
egal=0;
break;
}
}
}
}
return egal;
}
char* f_mot(char*x,char*mot)
{
char *search=NULL;
long long int longx,longmot;
if (x!=NULL && mot!=NULL)
{
longx=strlen(x);
longmot=strlen(mot);
}
else
{
longx=0;
longmot=0;
}
if (longx!=0 && longmot!=0)
{
int valide=f_egal(x,mot);
if (valide)
{
search=&x[0];
}
else
{
if (longmot<longx)
{
long long int limite=longx-longmot+1;
long long int compteur0,compteur,test;
for (compteur0=0;compteur0<limite;compteur0++)
{
test=0;
for (compteur=0;compteur<longmot;compteur++)
{
if (x[compteur0+compteur]==mot[compteur])
{
test++;
}
if (test==longmot)
{
search=&x[compteur0];
break;
}
}
if (search!=NULL)
{
break;
}
}
}
}
}
return search;
}
long long int f_intlong(int x)
{
long long int y=0;
int compteur,chiffre;
long long int lchiffre;
int divise=100000000;
long long int ldivise=100000000;
for (compteur=1;compteur<10;compteur++)
{
chiffre=x/divise;
x=x-(chiffre*divise);
switch (chiffre)
{
case 0:
lchiffre=0;
break;
case 1:
lchiffre=1;
break;
case 2:
lchiffre=2;
break;
case 3:
lchiffre=3;
break;
case 4:
lchiffre=4;
break;
case 5:
lchiffre=5;
break;
case 6:
lchiffre=6;
break;
case 7:
lchiffre=7;
break;
case 8:
lchiffre=8;
break;
case 9:
lchiffre=9;
break;
default :
exit(0);
}
y=y+(lchiffre*ldivise);
ldivise/=10;
divise/=10;
}
return y;
}
void f_space(char*chaine,int*type_,long long int*taille_)
{
f_size(chaine,type_,taille_);
if (*taille_>1)
{
long long int compteur,scompteur,suppression;
long long int taille=*taille_;
for (compteur=1;compteur<taille;compteur++)
{
if(compteur+1==taille&&chaine[compteur]==' ')
{
chaine[compteur]='\0';
compteur=taille;
}
else if (chaine[compteur]==' ')
{
scompteur=0;
do
{
scompteur++;
}while (chaine[compteur+scompteur]==' ');
if (chaine[compteur+scompteur]=='\0')
{
chaine[compteur]='\0';
compteur=taille;
}
else
{
chaine[compteur]=chaine[compteur+scompteur];
suppression=scompteur;
taille=taille-suppression;
for (scompteur=compteur+1;scompteur<taille;scompteur++)
{
chaine[scompteur]=chaine[scompteur+suppression];
}
chaine[taille]='\0';
}
}
}
}
}
void f_blank(char*chaine,long long int debut,long long int fin,int*type_,long long int*taille_)
{
f_size(chaine,type_,taille_);
long long int compteur,suppression;
suppression=fin-debut+1;
if (*taille_>1&&debut>=0&&fin<*taille_&&debut<=fin&&suppression<*taille_)
{
for (compteur=debut;compteur<*taille_-suppression;compteur++)
{
chaine[compteur]=chaine[compteur+suppression];
}
chaine[*taille_-suppression]='\0';
}
}
void f_unit(char*chaine,long long int cible,int*type_,long long int*taille_)
{
f_size(chaine,type_,taille_);
if (cible>=0&&cible<*taille_-1&&chaine[cible]==chaine[cible+1])
{
long long int compteur;
int test=1;
long long int debut=cible+1,fin=-1;
for (compteur=cible+1;compteur<*taille_;compteur++)
{
if (chaine[cible]!=chaine[compteur])
{
test=0;
fin=compteur-1;
break;
}
}
if (test)
{
fin=*taille_-1;
}
f_blank(chaine,debut,fin,type_,taille_);
}
}
void f_inv(char*chaine,int*type_,long long int*taille_)
{
f_size(chaine,type_,taille_);
char carac;
if (*taille_==2)
{
carac=chaine[0];
chaine[0]=chaine[1];
chaine[1]=carac;
}
else if (*taille_>2)
{
long long int compteur,taille,pair;
pair=*taille_%2;
if (pair==0)
{
taille=*taille_/2;
}
else
{
taille=(*taille_-1)/2;
}
for (compteur=0;compteur<taille;compteur++)
{
carac=chaine[compteur];
chaine[compteur]=chaine[*taille_-compteur-1];
chaine[*taille_-compteur-1]=carac;
}
}
}
void f_insert(char*chaine,char*chainon,long long int cible)
{
long long int t1;
long long int *t1_=&t1;
int p1;
int *p1_=&p1;
long long int t2;
long long int *t2_=&t2;
int p2;
int *p2_=&p2;
long long int compteur;
f_size(chaine,p1_,t1_);
f_size(chainon,p2_,t2_);
char*chainecopy=NULL;
chainecopy=malloc((t1+1)*sizeof(char));
if (chainecopy==NULL)
{
printf("echec f_insert\n");
exit(0);
}
chainecopy[t1]='\0';
if (t1>0)
{
for (compteur=0;compteur<t1;compteur++)
{
chainecopy[compteur]=chaine[compteur];
}
if (t2>=1&&t1>=t2&&cible>=0&&cible<=t1-t2)
{
if (cible!=t1-t2)
{
for (compteur=0;compteur<t1-t2-cible;compteur++)
{
chaine[t2+cible+compteur]=chainecopy[cible+compteur];
}
}
for (compteur=0;compteur<t2;compteur++)
{
chaine[cible+compteur]=chainon[compteur];
}
}
}
free(chainecopy);
}
void f_math(char*n_math,int*math_,int*type_,long long int*taille_,long long int*SEQUENCE,long long int*signe1_,long long int*signe2_,long long int*point1_,long long int*point2_,int*i_,int*signe_,int*point_,int*niveau_,int*categorie_)
{
/* informations sur les n_nombres */
/* SEQUENCE[] cellules des debuts et fin de sequences de chiffres par defaut valeur-1 */
/* niveau valeur de la cellule maximale de seq par defaut vaut 8 */
/* i quantité de i */
/* point quantité de points */
/* signe quantité de signes */
/* point1 cellule du premier point */
/* point2 cellule du second point */
/* signe1 cellule du premier signe */
/* signe2 cellule du second signe */
/* categories */
/* cat.I _-000 */
/* cat.II _-000i */
/* cat.III _-000.000 */
/* cat.IV _-000.000i */
/* cat.V _-000+-000i */
/* cat.VI _-000+-000.000i */
/* cat.VII _-000.000+-000i */
/* cat.VIII _-000.000+-000.000i */
/* cat.IX _-000+-i */
/* cat.X _-000.000+-i */
/* cat.XI _-i */
SEQUENCE[0]=-1,SEQUENCE[1]=-1,SEQUENCE[2]=-1,SEQUENCE[3]=-1,SEQUENCE[4]=-1,SEQUENCE[5]=-1,SEQUENCE[6]=-1,SEQUENCE[7]=-1;
*i_=0,*point_=0,*signe_=0,*niveau_=0,*categorie_=0,*math_=0;
*signe1_=-1,*signe2_=-1,*point1_=-1,*point2_=-1;
int i=0,point=0,signe=0,niveau=0;
long long int signe1=-1,signe2=-1,point1=-1,point2=-1;
long long int SEQ[8]={-1,-1,-1,-1,-1,-1,-1,-1};
f_size(n_math,type_,taille_);
/* *taille_ donne la taille de la chaine */
int codedebut,codefin,testdebut,testfin,imax,signemax,pointmax;
int code,exist,indic;
long long int compteur;
int test1,test2,test3,test4,test5,test6,test7;
int cat=0,categorie=0;
long long int taille,taillechaine,suppression;
long long int taillechainon;
long long int *taillechainon_=&taillechainon;
int typechainon;
int *typechainon_=&typechainon;
if (*taille_>0)
{
/*enleve espaces sauf au premier caractere et re-calcule la taille */
f_space(n_math,type_,taille_);
f_size(n_math,type_,taille_);
/*enleve l'espace situé au premier caractere s'il existe et recalcule la taille*/
codedebut=f_code(n_math,0);
if (codedebut==90)
{
f_blank(n_math,0,0,type_,taille_);
f_size(n_math,type_,taille_);
}
/* les espaces ont étés éliminés et la taille de la chaine a été recalculée */
codedebut=f_code(n_math,0);
codefin=f_code(n_math,*taille_-1);
/* codedebut donne le code du premier caractere */
/* codefin donne le code du dernier caractere */
if (*taille_==1)
/*traite bloc taille = 1 */
{
if (codedebut<=9||codedebut==44)
{
*math_=1;
if (codedebut<=9)
{
*math_=1,*categorie_=1,SEQUENCE[0]=0,SEQUENCE[1]=0,*niveau_=1,*categorie_=1;
}
else
{
*math_=1,*categorie_=11,*i_=1;
}
}
/* fin de bloc taille =1 */
}
}
if (*taille_>1)
{
testdebut=0,testfin=0,imax=0,signemax=0,pointmax=0;
if (codedebut<=9||codedebut==44||codedebut==63)
{
testdebut=1;
}
if (codefin<=9||codefin==44)
{
testfin=1;
}
if (testdebut==1&&testfin==1)
{
*math_=1;
}
if (*math_)
{
/* calcule imax et signemax et pointmax */
/* sont les quantités maximales de respectivement */
/* i signe et point */
if (codefin==44)
{
imax=1;
pointmax=2;
signemax=2;
}
else
{
imax=0;
pointmax=1;
if (codedebut==63)
{
signemax=1;
}
else
{
signemax=0;
}
}
}
}
if (*taille_>1&&*math_==1)
{
/* code avant lecture de chaine*/
exist=0,indic=0;
for (compteur=0;compteur<*taille_;compteur++)
{
/*debut de la boucle de lecture de chaine*/
code=f_code(n_math,compteur);
if (code<=9||code==44||code==63||code==64||code==67)
{
if (code>9)
{
if (exist==1)
{
SEQUENCE[*niveau_]=compteur-1;
*niveau_=*niveau_+1;
}
exist=0;
}
else
{
if (exist==0&&*niveau_<=7)
{
exist=1;
SEQUENCE[*niveau_]=compteur;
*niveau_=*niveau_+1;
}
if (exist==0&&*niveau_>7)
{
*math_=0;
break;
}
}
if (code==44)
{
*i_=*i_+1;
}
if (code==63||code==64)
{
*signe_=*signe_+1;
if (*signe_==1)
{
*signe1_=compteur;
}
if (*signe_==2)
{
*signe2_=compteur;
}
}
if (code==67)
{
*point_=*point_+1;
if (*point_==1)
{
*point1_=compteur;
}
if (*point_==2)
{
*point2_=compteur;
}
}
if (*i_>imax||*signe_>signemax||*point_>pointmax)
{
*math_=0;
}
}
else
{
*math_=0;
}
if (!*math_)
{
break;
}
if (code<=9&&compteur==*taille_-1)
{
SEQUENCE[*niveau_]=compteur;
indic=1;
}
/*fin de boucle de lecture*/
}
if (indic==0&&*niveau_>0)
{
*niveau_=*niveau_-1;
}
if (*taille_==2&&*i_==1&&*signe_==1)
{
*categorie_=11;
}
}
if (*taille_>1&&*math_==1&&*niveau_>0)
{
/* verification des quatre regles */
test1=1,test2=1,test3=1,test4=1,test5=1,test6=1,test7=1;
/* regle 1: interdiction que deux signes soient adjacents */
/* regle 2: si il existe deux signes alors la chaine commence par moins */
if (*signe_==2)
{
if (*signe1_==*signe2_-1)
{
test1=0;
}
if (codedebut!=63)
{
test2=0;
}
}
/*regle 3: tout point est adjacent à deux chiffres*/
if (*point_==1)
{
if (f_code(n_math,*point1_-1)>9||f_code(n_math,*point1_+1)>9)
{
test3=0;
}
}
if (*point_==2)
{
if (f_code(n_math,*point1_-1)>9||f_code(n_math,*point1_+1)>9)
{
test4=0;
}
if (f_code(n_math,*point2_-1)>9||f_code(n_math,*point2_+1)>9)
{
test5=0;
}
/*regle 4: si il existe deux points alors il existe un signe entre ces deux points */
if (*signe_==1)
{
if (*signe1_<*point1_||*signe1_>*point2_)
{
test6=0;
}
}
if (*signe_==2)
{
if (*signe2_<*point1_||*signe2_>*point2_)
{
test7=0;
}
}
}
if (test1==0||test2==0||test3==0||test4==0||test5==0||test6==0||test7==0)
{
*math_=0;
}
}
if (*niveau_==0&&SEQUENCE[0]==-1&&SEQUENCE[1]==-1&&SEQUENCE[2]==-1&&SEQUENCE[3]==-1&&SEQUENCE[4]==-1&&SEQUENCE[5]==-1&&SEQUENCE[6]==-1&&SEQUENCE[7]==-1)
{
cat=1;
}
if (*niveau_==1&&SEQUENCE[0]!=-1&&SEQUENCE[1]!=-1&&SEQUENCE[2]==-1&&SEQUENCE[3]==-1&&SEQUENCE[4]==-1&&SEQUENCE[5]==-1&&SEQUENCE[6]==-1&&SEQUENCE[7]==-1)
{
cat=1;
}
if (*niveau_==3&&SEQUENCE[0]!=-1&&SEQUENCE[1]!=-1&&SEQUENCE[2]!=-1&&SEQUENCE[3]!=-1&&SEQUENCE[4]==-1&&SEQUENCE[5]==-1&&SEQUENCE[6]==-1&&SEQUENCE[7]==-1)
{
cat=1;
}
if (*niveau_==5&&SEQUENCE[0]!=-1&&SEQUENCE[1]!=-1&&SEQUENCE[2]!=-1&&SEQUENCE[3]!=-1&&SEQUENCE[4]!=-1&&SEQUENCE[5]!=-1&&SEQUENCE[6]==-1&&SEQUENCE[7]==-1)
{
cat=1;
}
if (*niveau_==7&&SEQUENCE[0]!=-1&&SEQUENCE[1]!=-1&&SEQUENCE[2]!=-1&&SEQUENCE[3]!=-1&&SEQUENCE[4]!=-1&&SEQUENCE[5]!=-1&&SEQUENCE[6]!=-1&&SEQUENCE[7]!=-1)
{
cat=1;
}
if (!cat)
{
*math_=0;
}
if (*math_==1&&*taille_>1&&*niveau_>0)
/* ici la chaine comporte au moins une sequence de chiffres */
/* en premier lieu on evalue la valeur de *categorie_ */
/* categorie est cette evaluation qui n'est pas definitive */
/* categorie a été initialisé à 0 au debut de la fonction*/
/* les évaluation des categories vont de 1 à 10 */
{
if (*signe1_==0&&f_code(n_math,0)==63&&f_code(n_math,1)<=9)
{
if (*i_==0&&f_code(n_math,*taille_-1)<=9)
{
if (*niveau_==1)
{
if (*signe_==1&&*point_==0&&*signe2_==-1&&*point1_==-1&&*point2_==-1)
{
categorie=1;
}
}
if (*niveau_==3)
{
if(*signe_==1&&*point_==1&&*signe2_==-1&&*point2_==-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=3;
}
}
}
if (*i_==1&&f_code(n_math,*taille_-1)==44)
{
if (*niveau_==1)
{
if (*signe_==1&&*point_==0&&*signe2_==-1&&*point1_==-1&&*point2_==-1)
{
categorie=2;
}
if (*signe_==2&&*point_==0&&*signe2_==*taille_-2&&*signe2_==SEQUENCE[1]+1&&*point1_==-1&&*point2_==-1)
{
categorie=9;
}
}
if (*niveau_==3)
{
if (*signe_==1&&*point_==1&&*signe2_==-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=4;
}
if (*signe_==2&&*point_==0&&*signe2_==SEQUENCE[1]+1&&*signe2_==SEQUENCE[2]-1&&*point1_==-1&&*point2_==-1)
{
categorie=5;
}
if (*signe_==2&&*point_==1&&*point2_==-1&&*signe2_==*taille_-2&&*signe2_==SEQUENCE[3]+1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=10;
}
}
if (*niveau_==5)
{
if (*signe_==2&&*point_==1&&*point2_==-1&&*signe2_==SEQUENCE[1]+1&&*signe2_==SEQUENCE[2]-1&&*point1_==SEQUENCE[3]+1&&*point1_==SEQUENCE[4]-1)
{
categorie=6;
}
if (*signe_==2&&*point_==1&&*point2_==-1&&*signe2_==SEQUENCE[3]+1&&*signe2_==SEQUENCE[4]-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=7;
}
}
if (*niveau_==7)
{
if (*signe_==2&&*point_==2&&*signe2_==SEQUENCE[3]+1&&*signe2_==SEQUENCE[4]-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1&&*point2_==SEQUENCE[5]+1&&*point2_==SEQUENCE[6]-1)
{
categorie=8;
}
}
}
}
if (*signe1_!=0)
{
if (*i_==0&&f_code(n_math,*taille_-1)<=9)
{
if (*niveau_==1)
{
if (*signe_==0&&*point_==0&&*signe1_==-1&&*signe2_==-1&&*point1_==-1&&*point2_==-1)
{
categorie=1;
}
}
if (*niveau_==3)
{
if(*signe_==0&&*point_==1&&*point2_==-1&&*signe1_==-1&&*signe2_==-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=3;
}
}
}
if (*i_==1&&f_code(n_math,*taille_-1)==44)
{
if (*niveau_==1)
{
if (*signe_==0&&*point_==0&&*signe1_==-1&&*signe2_==-1&&*point1_==-1&&*point2_==-1)
{
categorie=2;
}
if (*signe_==1&&*point_==0&&*signe2_==-1&&*signe1_==*taille_-2&&*signe1_==SEQUENCE[1]+1&&*point1_==-1&&*point2_==-1)
{
categorie=9;
}
}
if (*niveau_==3)
{
if (*signe_==0&&*point_==1&&*signe1_==-1&&*signe2_==-1&&*point2_==-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=4;
}
if (*signe_==1&&*point_==0&&*point1_==-1&&*point2_==-1&&*signe1_==SEQUENCE[1]+1&&*signe1_==SEQUENCE[2]-1)
{
categorie=5;
}
if (*signe_==1&&*point_==1&&*signe2_==-1&&*point2_==-1&&*signe1_==*taille_-2&&*signe1_==SEQUENCE[3]+1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=10;
}
}
if (*niveau_==5)
{
if (*signe_==1&&*point_==1&&*signe2_==-1&&*point2_==-1&&*signe1_==SEQUENCE[1]+1&&*signe1_==SEQUENCE[2]-1&&*point1_==SEQUENCE[3]+1&&*point1_==SEQUENCE[4]-1)
{
categorie=6;
}
if (*signe_==1&&*point_==1&&*signe2_==-1&&*point2_==-1&&*signe1_==SEQUENCE[3]+1&&*signe1_==SEQUENCE[4]-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1)
{
categorie=7;
}
}
if (*niveau_==7)
{
if (*signe_==1&&*point_==2&&*signe2_==-1&&*signe1_==SEQUENCE[3]+1&&*signe1_==SEQUENCE[4]-1&&*point1_==SEQUENCE[1]+1&&*point1_==SEQUENCE[2]-1&&*point2_==SEQUENCE[5]+1&&*point2_==SEQUENCE[6]-1)
{
categorie=8;
}
}
}
}
if (categorie==0)
{
*math_=0;
}
*categorie_=categorie;
}
if (categorie!=0)
{
i=*i_;
signe=*signe_;
point=*point_;
niveau=*niveau_;
point1=*point1_;
point2=*point2_;
signe1=*signe1_;
signe2=*signe2_;
SEQ[0]=SEQUENCE[0];
SEQ[1]=SEQUENCE[1];
SEQ[2]=SEQUENCE[2];
SEQ[3]=SEQUENCE[3];
SEQ[4]=SEQUENCE[4];
SEQ[5]=SEQUENCE[5];
SEQ[6]=SEQUENCE[6];
SEQ[7]=SEQUENCE[7];
if (categorie==1)
{
suppression=0;
*taillechainon_=SEQUENCE[1]-SEQUENCE[0]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[0]+compteur];
}
taille=*taillechainon_;
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[0],SEQUENCE[1],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[0]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[1]=SEQUENCE[1]-suppression;
}
free(chainon);
}
}
if (categorie==2)
{
suppression=0;
*taillechainon_=SEQUENCE[1]-SEQUENCE[0]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[0]+compteur];
}
taille=*taillechainon_;
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[0],SEQUENCE[1],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[0]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[1]=SEQUENCE[1]-suppression;
}
free(chainon);
}
/* categorie II */
if (SEQUENCE[0]==0&&SEQUENCE[0]==SEQUENCE[1])
{
*categorie_=1;
i=0;
signe=0;
point=0;
niveau=1;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
if (SEQUENCE[0]==1&&SEQUENCE[0]==SEQUENCE[1])
{
*categorie_=11;
i_=0;
signe=0;
point=0;
niveau=0;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
}
if (categorie==3)
{
suppression=0;
*taillechainon_=SEQUENCE[1]-SEQUENCE[0]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[0]+compteur];
}
taille=*taillechainon_;
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[0],SEQUENCE[1],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[0]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[1]=SEQUENCE[1]-suppression;
SEQUENCE[2]=SEQUENCE[2]-suppression;
SEQUENCE[3]=SEQUENCE[3]-suppression;
*point1_=*point1_-suppression;
}
free(chainon);
}
suppression=0;
*taillechainon_=SEQUENCE[3]-SEQUENCE[2]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[2]+compteur];
}
taille=*taillechainon_;
f_inv(chainon,typechainon_,taillechainon_);
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
f_inv(chainon,typechainon_,taillechainon_);
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[2],SEQUENCE[3],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[2]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[3]=SEQUENCE[3]-suppression;
}
free(chainon);
}
/* categorie III */
if (SEQUENCE[2]==0&&SEQUENCE[2]==SEQUENCE[3])
{
*categorie_=1;
i=0;
signe=0;
point=0;
niveau=0;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
}
if (categorie==4)
{
suppression=0;
*taillechainon_=SEQUENCE[1]-SEQUENCE[0]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[0]+compteur];
}
taille=*taillechainon_;
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[0],SEQUENCE[1],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[0]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[1]=SEQUENCE[1]-suppression;
SEQUENCE[2]=SEQUENCE[2]-suppression;
SEQUENCE[3]=SEQUENCE[3]-suppression;
*point1_=*point1_-suppression;
}
free(chainon);
}
suppression=0;
*taillechainon_=SEQUENCE[3]-SEQUENCE[2]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[2]+compteur];
}
taille=*taillechainon_;
f_inv(chainon,typechainon_,taillechainon_);
code=f_code(chainon,0);
if (code==0)
{
f_unit(chainon,0,typechainon_,taillechainon_);
f_size(chainon,typechainon_,taillechainon_);
if (*taillechainon_>1)
{
f_blank(chainon,0,0,typechainon_,taillechainon_);
*taillechainon_=*taillechainon_-1;
}
suppression=taille-*taillechainon_;
f_inv(chainon,typechainon_,taillechainon_);
taillechaine=*taille_;
f_blank(n_math,SEQUENCE[2],SEQUENCE[3],type_,taille_);
for (compteur=0;compteur<taille;compteur++)
{
n_math[taillechaine-taille+compteur]='0';
}
n_math[taillechaine]='\0';
f_insert(n_math,chainon,SEQUENCE[2]);
n_math[taillechaine-suppression]='\0';
f_size(n_math,type_,taille_);
SEQUENCE[3]=SEQUENCE[3]-suppression;
}
free(chainon);
}
/* categorie IV */
if (SEQUENCE[0]==0&&SEQUENCE[0]==SEQUENCE[1]&&SEQUENCE[2]==0&&SEQUENCE[2]==SEQUENCE[3])
{
*categorie_=1;
i=0;
signe=0;
point=0;
niveau=0;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
if (SEQUENCE[0]==1&&SEQUENCE[0]==SEQUENCE[1]&&SEQUENCE[2]==0&&SEQUENCE[2]==SEQUENCE[3])
{
*categorie_=11;
i=0;
signe=0;
point=0;
niveau=0;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
if (SEQUENCE[2]==0&&SEQUENCE[2]==SEQUENCE[3])
{
*categorie_=2;
i=0;
signe=0;
point=0;
niveau=0;
point1=-1;
point2=-1;
signe1=-1;
signe2=-1;
SEQ[0]=-1;
SEQ[1]=-1;
SEQ[2]=-1;
SEQ[3]=-1;
SEQ[4]=-1;
SEQ[5]=-1;
SEQ[6]=-1;
SEQ[7]=-1;
}
}
if (categorie==5)
{
suppression=0;
*taillechainon_=SEQUENCE[1]-SEQUENCE[0]+1;
if (*taillechainon_>1)
{
char *chainon=NULL;
chainon=malloc((*taillechainon_+1)*sizeof(char));
if (chainon==NULL)
{
exit(0);
}
chainon[*taillechainon_]='\0';
for (compteur=0;compteur<*taillechainon_;compteur++)
{
chainon[compteur]=n_math[SEQUENCE[0]+compteur];
}
taille=*taillechainon_;
code=f_code(chainon,0);
if (code==0)
{