#include #include #include #include #include "Conjunto.h" #include "Processor.h" #define maximo_conjuntos 100 #define maximo_operaciones 100 #define maximo_caracteres 100 void LeerDatos(ifstream & infile) { char datos[maximo_conjuntos][maximo_caracteres], operaciones[maximo_operaciones][maximo_caracteres],p; string respuesta; int cantidad_datos=0, puntero_conjunto=0, numero=0, cantidad_operaciones=0, puntero_respuesta,contador_respuestas_correctas=0; float porcentaje; Conjunto conjuntos[maximo_conjuntos], respuesta_conjunto, respuesta_correcta; infile >> datos[0]; while('%' != datos[cantidad_datos][0]) //Rescatando cantidad de conjuntos y creando arreglo de conjuntos { puntero_conjunto=0; while('{' != datos[cantidad_datos][puntero_conjunto]) puntero_conjunto++; puntero_conjunto++; while('}' != datos[cantidad_datos][puntero_conjunto]) { numero=0; if((datos[cantidad_datos][puntero_conjunto]<'0')||(datos[cantidad_datos][puntero_conjunto]>'9')) puntero_conjunto++; else { while((datos[cantidad_datos][puntero_conjunto]>='0')&&(datos[cantidad_datos][puntero_conjunto]<='9')) { numero=numero*10+datos[cantidad_datos][puntero_conjunto]-48; puntero_conjunto++; } conjuntos[cantidad_datos].AgregarElemento(numero); } } cantidad_datos++; infile >> datos[cantidad_datos]; } infile >> operaciones[cantidad_operaciones]; while( !infile.eof()) //Rescatando cantidad de operaciones { cantidad_operaciones++; infile >> operaciones[cantidad_operaciones]; } for(int i=0;i'9')) puntero_respuesta++; else { while((respuesta[puntero_respuesta]>='0')&&(respuesta[puntero_respuesta]<='9')) { numero=numero*10+respuesta[puntero_respuesta]-48; puntero_respuesta++; } respuesta_conjunto.AgregarElemento(numero); } } Processor respuesta(operaciones[i], conjuntos, datos); respuesta_correcta=respuesta.retorno(); //Respuesta correcta if(respuesta_conjunto==respuesta_correcta) //Comparacion de respuestas { cout <<"Respuesta Correcta"<>ayuda; if(ayuda[0]==l) goto cuenta; } cuenta:; while(!arch.eof()) { arch>>ayuda; i++; } return i; } void runtest(char *test, int j, int f) //Comprobacion de sintaxis { //Para lo anterior, evalua problemas de operadores, variables, o parantesis int a=0,b=0,c=0,d=1,a3=1,t1=1; //operaciones al comienzo o final// int a1=((test[0]=='+')||(test[0]=='*')); int l2=((test[f-2]=='+')||(test[f-2]=='*')); if((a1||l2)==1) { cout<<"Error de operacion en la linea "<='A')&&(test[z]<='Z')); int w1=((test[z+1]>='A')&&(test[z+1]<='Z')); if((q1&&w1)==1) { cout<<"\nError de operando en la operacion "< [v]\n" << endl; return 0 ; } if (argc == 2) //Caso sin v { file.open(argv[1]); LeerDatos(file); // Obteniedo datos y luego procesarlos file.close(); } if (argc==3) //Caso con v { system("clear"); cout << "Revisando sintaxis de las operaciones:" << endl; ifstream fin,know; int i=0,k=0,b; char operaciones[50]; char basura[50]; char j='%'; fin.open(argv[1]); know.open(argv[1]); b=opcount(know); //nš lineas de operaciones en el archivo while(basura[0]!=j) { fin>>basura; } for(int z=0;z>operaciones; while(operaciones[k]!='i') { k++; } i++; runtest(operaciones, i, k); // Comprobando sintaxis operaciones } cout<<"\n\nRevision de sintaxis completada."<