"CÓDIGO DE PROGRAMACIÓN C++"
/* AUTOMATAS Y LENGUAJES FORMALES*/
/* AUTHOR: JUAN CARLOS CELESTINO GUILLERMO*/
/* ICO-19*/
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
void operacion_letras(char A[],char B[],int,int);
char
concatenacion(char A[], char B[]);
int main(int argc, char** argv) {
int
cantValores;
int codigo;
int n1, n2;
printf("\n\t\t
ALUMNO: JUAN CARLOS CELESTINO GUILLERMO.%c\n",169);
printf("\t\t MATERIA: AUTOMATAS Y
LENGUAJES FORMALES.%c\n",184);
cout << "\t\t GRUPO: ICO-19.
" << endl;
cout << "\t\t 2o SEMESTRE.
" << endl;
cout << "\t\t PROGRAMA:
EXPRESIONES REGULARES(UNION Y CONCATENACION). \n" << endl;
cout << "\nCODIGO PARA LA UNION
Y CONCATENACION"<<endl;
cout << "\t1. ALFABETO CON
NUMEROS. " << endl;
cout << "ELIGE LA UNICA OPCION
: ";
cin >> codigo;
if ( codigo
== 1 ){
cout
<<
"_______________________________________________"
<< endl;
cout
<< "\n\t\t\t[ EXPRESIONES REGULARES ]" << endl;
cout
<< "\n --------------------------------------------" <<
endl;
cout
<< "| <SIMBOLOGIA>\t |" << endl;
cout << "| & =
ELEMENTO VACIO EN EL CONJUNTO. |"
<< endl;
cout << "
--------------------------------------------" << endl;
cout << "\nCANTIDAD DE
VALORES EN EL PRIMER CONJUNTO [A]: ";
cin >> n1;
if
('&'== n1){
cout
<< '&' << endl;
}
if
('0'== n1){
cout
<< '0' << endl;
}
if
('1'== n1){
cout
<< '1' << endl;
}
if
('2'== n1){
cout
<< '2' << endl;
}
if
('3'== n1){
cout
<< '3' << endl;
}
if
('4'== n1){
cout
<< '4' << endl;
}
if
('5'== n1){
cout
<< '5' << endl;
}
if
('6'== n1){
cout
<< '6' << endl;
}
if
('6'== n1){
cout
<< '6' << endl;
}
if
('7'== n1){
cout
<< '7' << endl;
}
if
('8'== n1){
cout
<< '8' << endl;
}
if
('9'== n1){
cout
<< '9' << endl;
}
char
cadenaA[n1];
for(int
i = 0; i < n1; i++){
cout
<< "\tINGRESA EL VALOR EN EL CONJUNTO [A]: ";
cin >> cadenaA[i];
}
cout << "\nCANTIDAD DE
VALORES EN EL SEGUNDO CONJUNTO [B]: ";
cin >> n2;
char cadenaB[n2];
for( int x = 0; x < n2; x++){
cout
<< "\tINGRESA EL VALOR EN EL CONJUNTO [B]: ";
cin >> cadenaB[x];
}
cout << "\n\t\tEL
CONJUNTO [A] ES = { ";
for(int y = 0; y < n1; y++){
cout << cadenaA[y] << ", ";
}
cout
<< "}. " << endl;
cout
<< "\t\tEL CONJUNTO [B] ES = { ";
for(int z = 0; z < n2; z++){
cout
<< cadenaB[z] << ", ";
}
cout
<< "}. " << endl;
operacion_letras(cadenaA,cadenaB,n1,n2);
}
return 0;
}
void operacion_letras(char A[], char B[],int n1, int
n2){
int cont=0;
cout
<< "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ " << endl;
cout
<< "\nEXPRESION REGULAR DE CONCATENACION = { ";
while(cont
!= n1){
for (int b = 0; b < n2; b++){
cout << A[cont] << B[b]
<< ", ";
}
cont++;
}
cout
<< "}. " << endl;
int mayor;
if(n1 <=
n2){
mayor=n2;
}
else{
mayor=n1;
}
int num=0;
while(num
!= mayor){
for
(int d = 0; d < mayor; d++){
if(A[num]
== B[d]){
B[d]=0;
}
}
num++;
}
cout
<< "\nEXPRESION REGULAR DE UNION = { ";
for(int i =
0; i < n1; i++){
cout
<< A[i];
cout
<< ", ";
}
for(int x =
0; x < n2; x++){
cout
<< B[x];
cout
<< ", ";
}
cout
<< "}. " << endl;
}
No hay comentarios.:
Publicar un comentario