Hola, tenemos la respuesta a lo que buscabas, continúa leyendo y la hallarás a continuación.
Ejemplo 1: convertidor de código c a código python en línea
#include // Defining MAX size to 10#define MAX 10
using namespace std;
typedef struct Edge
int source;int destination;int weight;Edge;
void bellman_ford_algo(int nodevertex,Edge edge[],int source_graph,int nodeedge)int u,v,weight,i,j=0;int distance[MAX];for(i=0;i<nodevertex;i++)
distance[i]=999;// distance of source vertex
distance[source_graph]=0;// free all the edges nodevertex -1 times
for(i=0;i<nodevertex-1;i++)for(j=0;j<nodeedge;j++)
u=edge[j].source;
v=edge[j].destination;
weight=edge[j].weight;if(distance[u]!=999&& distance[u]+weight < distance[v])
distance[v]=distance[u]+weight;// checking for negative cycle
for(j=0;j<nodeedge;j++)
u=edge[j].source;
v=edge[j].destination;
weight=edge[j].weight;if(distance[u]+weight < distance[v])
cout<<"nnNegative Cycle present..!!n";return;
cout<<"nVertex"<<" Distance from source";for(i=1;i<=nodevertex;i++)
cout<<"n"<<i<<"t"<<distance[i];int main()int nodevertex,nodeedge,source_graph;
Edge edge[MAX];
cout<<"Enter the number of vertices you want : ";
cin>>nodevertex;
printf("Enter the source vertex of the graph: ");
cin>>source_graph;
cout<<"nEnter no. of edges you want : ";
cin>>nodeedge;for(int i=0;i<nodeedge;i++)
cout<<"nEdge Number "<<i+1<<"=";
cout<<"nEnter source vertex here :";
cin>>edge[i].source;
cout<<"Enter destination vertex here:";
cin>>edge[i].destination;
cout<<"Enter weight here :";
cin>>edge[i].weight;
bellman_ford_algo(nodevertex,edge,source_graph,nodeedge);return0;
Ejemplo 2: convertidor de python a c
import sys
defmergesort_2ndstep(l, r):
len_l =len(l)
len_r =len(r)# initializing a list of length zero
sorted_array =[]
i,j =0,0while i < len_l:
num1 = l[i]for x inrange(j,len_r):
num2 = r[x]if num2 < num1 :
sorted_array.append(num2)
j +=1
sorted_array.append(num1)
i +=1iflen(sorted_array)!= len_l + len_r:# Checking extreme conditions
sorted_array[i+j:]= r[j:]return sorted_array
defmergesort_1ststep(L,start,stop):# a list can be divided into two # if length of list is atleast twoif stop - start >1:
l = mergesort_1ststep(L,start,start +(stop-start)//2)
r = mergesort_1ststep(L,start +(stop-start)//2,stop)# mergeing two lists(sorting the l and r parts)
L[start:stop]= mergesort_2ndstep(l,r)return L[start:stop]# START
List_of_nums =[]
file_to_open ="input1.txt"try:
read_file =open(file_to_open,"r")
write_file =open("output.txt","w")if read_file !=None:# appending every num from file to list_of_numsfor line in read_file:
line =int(line)
List_of_nums.append(line)# applying mergesort
mergesort_1ststep(List_of_nums,0,len(List_of_nums))# writing to an output file# excluding the last element
k = List_of_nums.pop()for num in List_of_nums:
write_file.write(f"numn")# writing last element without next line
write_file.write(f"k")# closing files
read_file.close()
write_file.close()except:print("file not found")
Ejemplo 3: convertidor de python a c en línea
np.linspace(0,1,11)
Tienes la opción de ayudar nuestra publicación poniendo un comentario o valorándolo te damos las gracias.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)