Answers for "python to c converter online"

0

c code to python code converter online

#include<iostream>
// 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<<"\n\nNegative 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);

  return 0;
}
Posted by: Guest on March-27-2021
0

online c code to python code conversion

#include<stdio.h>
using namespace std;
void main()
{
  for (int i=1, i<=5, i++)
  {
    for(int j=1, j<=i,j++)
    {
      printf("%c",64+j)
    }
    printf("\n")
  }
}
Posted by: Guest on April-24-2021
0

python to c converter tool online

import math
x,y=input().split(),input().split()
x,y=[int(i) for i in x],[int(i) for i in y]
t,t1=abs(x[0]-y[0]),abs(x[1]-y[1])

print("%.2f" %math.sqrt(t*t+t1*t1))
Posted by: Guest on July-04-2021
0

convert python code to C code

def ReadMatrix():
    matrix = []
    for i in range(int(input())):
        row = [int(j) for j in input().split()]
        matrix.append(row) 
    return matrix

def RotateMatrix(matrix, degrees):
    n = len(matrix[0])
    rotations = (degrees // 90) % 4
    for r in range(rotations):
        temp_matrix = []
        for i in range(n):
            column = [row[i] for row in matrix]
            column.reverse()
            temp_matrix.append(column)
        matrix = temp_matrix
    return matrix

matrix = ReadMatrix()
rotation = 0

while True:
    line = input().split()
    if line[0] == "-1":
        break;
    elif line[0] == "R":
        rotation += int(line[1])
        matrix = RotateMatrix(matrix, int(line[1]))
    elif line[0] == "U":
         matrix[int(line[1])][int(line[2])] = int(line[3])
         matrix = RotateMatrix(matrix, rotation)
    elif line[0] == "Q":
        print(matrix[int(line[1])][int(line[2])]) 
    else:
        print(line[0])
        exit(1)
Posted by: Guest on June-07-2021
0

python code to c code converter

class Buffer:

    def __init__(self,size_max):
        self.max = size_max
        self.data = []

    class __Full:

        def append(self, x):

            self.data[self.cur] = x
            self.cur = (self.cur+1) % self.max
        def get(self):

            return self.data[self.cur:]+self.data[:self.cur]

    def append(self,x):

        self.data.append(x)
        if len(self.data) == self.max:
            self.cur = 0

            self.__class__ = self.__Full

    def get(self):

        return self.data


if __name__=='__main__':
    n=input('Enter the occupide size of the buffer : ')
    x=Buffer(int(n))

    x.append(1); x.append(2); x.append(3); x.append(4)

    print (x.__class__, x.get(  ))
    l=len(x.data)
    print(f"The free buffer is :{l}")
    print(f"The left size buffer is :{int(n)-int(l)}")

    x.append(5)

    print (x.__class__, x.get(  ))
    x.append(6)
    print (x.data, x.get(  ))
    x.append(7); x.append(8); x.append(9); x.append(10)
    print (x.data, x.get(  ))
Posted by: Guest on April-14-2021
0

python to c converter online

np.linspace(0,1,11)
Posted by: Guest on April-09-2021

Code answers related to "python to c converter online"

Python Answers by Framework

Browse Popular Code Answers by Language