Answers for "convert python to c++"

0

python to c++ transpiler

# Note: The last time I tested something was missing so I couldn't work
import pathlib
import transpyle

path = pathlib.Path('my_script.py')
code_reader = transpyle.CodeReader()
code = code_reader.read_file(path)

from_language = transpyle.Language.find('Python 3.6')
to_language = transpyle.Language.find('Fortran 95')
translator = transpyle.AutoTranslator(from_language, to_language)
fortran_code = translator.translate(code, path)
print(fortran_code)
Posted by: Guest on June-16-2020
0

"convertir python a c ++

import sys

total=0 #cuenta el total de pixeles
cont=0 #cuanta aquellos <=1

def Leer (archivo):
     global total
     global cont
     f=open(archivo,'r')
     while(1):
        linea=f.readline()
        linea=linea[:-1]
####
        if(len(linea)>0):
          y=linea.split(";")
          print(y)
          total=total+len(y)
          for i in range(len(y)):
            if(int(y[i])<=1):
                cont+=1
	####
        if not linea:
            break
     f.close()
####
Leer ("imagen.txt")
print (total)

while(1):
	print("1.Cargar Imagenn 2.Evaluar Imagenn 3.salirn")
	x=int(input("Ingrese una opcion:n"))
	
	if (x==1):
		total=0
		cont=0 
		print("Cargar Imagen")
		Leer("imagen.txt")
	
	if(x==2):
		print("Evaluando imagen")
		print("TOTAL:"+str(total))
		print("CONT:"+str(cont))
	
		p=(cont/total)*100
	
		if(p>=50):
			print("Probabilidad de cobre: ALTA")
		if(p>=30 and p<50):
			print("Probabilidad de cobre: MEDIA")
		if(p<50):
			print("Probabilidad de cobre: BAJA")
	if(x==3):
		print("adios")	
		sys.exit(0)
Posted by: Guest on June-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language