<jupyter_start><jupyter_text><jupyter_code>class Stack:
  def __init__(self):
    self.__datos = []
    
  def is_empty(self):
    return len(self.__datos) == 0

  def get_top(self):
    return self.__datos[-1]

  def pop(self):
    return self.__datos.pop()

  def push(self,valor):
    self.__datos.append(valor)

  def get_length(self):  
    return len(self.__datos)

  def to_string(self):
    print("|----------|")
    for i in self.__datos[-1::-1]:
      print(i)
    print("|----------|")
    print()


def main():
    pila1 = Stack()
    pila2 = Stack()
    pila3 = Stack()
    bandera1 = 0
    bandera2 = 0
    bandera3 = 0

    cod="""
        int main(){
	float peso;
	float altura;
	float imc;
	
	//Captura el peso y la estatura
	printf("Ingresa tu peso: "); scanf("%f", &peso);
	printf("Ingresa tu estatura: "); scanf("%f", &altura);
	
	//Calcula el Indice de Masa Corporal
	imc=peso/(altura*altura);
	
	//Muestta en pantalla el Indice de Masa Corporal
	printf("Tu IMC es: %f \n\n\n", imc);
	
	system("pause");
	return 0;
      }"""
    print(cod[0])

    for i in range(0,len(cod)):
        if cod[i] == "(":
            pila1.push("+")
        if cod[i] == ")":
            try:
                pila1.pop()
            except:
                bandera1 = 1
                
    for i in range(0,len(cod)):
        if cod[i] == "[":
            pila2.push("+")
        if cod[i] == "]":
            try:
                pila2.pop()
            except:
                bandera2 = 1

    for i in range(0,len(cod)):
        if cod[i] == "{":
            pila3.push("+")
        if cod[i] == "}":
            try:
                pila3.pop()
            except:
                bandera3 = 1
    if bandera1 == 0 and bandera2 == 0 and bandera3 == 0 and pila1.get_length() == 0 and pila2.get_length() == 0 and pila3.get_length() == 0:
        print("El código C está balanceado")
    else:
        print("El código C no esta balanceado")
################################################################################
    pila1a = Stack()
    pila2a = Stack()
    pila3a = Stack()
    bandera1a = 0
    bandera2a = 0
    bandera3a = 0

    cod1="""
    public Automoviles() {
    }

    public Automoviles(String marca, String modelo, int anio, float precio, String color, int numPuer, String matricula,
    String aceleracion, String potencia, String velMax) {
        this.marca = marca;
        this.modelo = modelo;
        this.anio = anio;
        this.precio = precio;
        this.color = color;
        this.numPuer = numPuer;
        this.matricula = matricula;
        this.aceleracion = aceleracion;
        this.potencia = potencia;
        this.velMax = velMax;
    } """
    print(cod1[0])

    for x in range(0,len(cod1)):
        if cod1[x] == "(":
            pila1a.push("+")
        if cod1[x] == ")":
            try:
                pila1a.pop()
            except:
                bandera1a = 1
                
    for x in range(0,len(cod1)):
        if cod1[x] == "[":
            pila2a.push("+")
        if cod1[x] == "]":
            try:
                pila2a.pop()
            except:
                bandera2a = 1

    for x in range(0,len(cod1)):
        if cod1[x] == "{":
            pila3a.push("+")
        if cod1[x] == "}":
            try:
                pila3a.pop()
            except:
                bandera3a = 1
    if bandera1a == 0 and bandera2a == 0 and bandera3a == 0 and pila1a.get_length() == 0 and pila2a.get_length() == 0 and pila3a.get_length() == 0:
        print("El código Java está balanceado")
    else:
        print("El código Java no esta balanceado")
 
main()<jupyter_output>El código C está balanceado


El código Java está balanceado
{'fraction_non_alphanumeric': 0.16356777149016438, 'fraction_numerical': 0.024252223120452707, 'mean_word_length': 1.7516679021497406, 'pattern_counts': {'":': 12, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '653148', 'license': 'MIT', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1281, 'n_words': 310, 'path': 'Tarea2Pilas.ipynb', 'repo_name': 'MoisesAcostaNava/daa_2021_1', 'size': '3711'}