convert python code to c online

Solutions on MaxInterview for convert python code to c online by the best coders in the world

showing results for - "convert python code to c online"
Camil
29 Jan 2020
1ALGORITMO
2DECLARE num[5,4] NUMÉRICO
3 num_aux, i, j, k, l, m, n, lin, col NUMÉRICO
4PARA i ← 1 ATÉ 5 FAÇA
5INÍCIO
6PARA j ← 1 ATÉ 4 FAÇA
7INÍCIO
8LEIA num_aux
9IF i = 1 E j = 1
10ENTÃO num[i, j] ← num_aux
11SENÃO INICIO
12 k ← 1
13 l ← 1
14 ENQUANTO num[k, l] < num_aux E (k  i OU l  j) FAÇA
15 INÍCIO
16 l ← l + 1
17 SE l > 4
18 ENTÃO INÍCIO
19 k ← k + 1
20 l ← 1
21 FIM
22 FIM
23 m ← i;
24 n ← j;
25 ENQUANTO m  k OU n  l FAÇA
26 INÍCIO
27 SE n-1 < 1 ENTÃO
28 INÍCIO
29 lin ← m-1
30 col ← 4
31 FIM
32 SENÃO INÍCIO
33 lin ← m
34 col ← n-1
35 FIM
36 num[m][n] ← num[lin][col]
37 n ← n-1
38 SE n < 1
39 ENTÃO INÍCIO
40 n ← 4
41 m ← m-1
42 FIM
43 FIM
44 num[k][l] ← num_aux
45 FIM
46FIM
47FIM
48PARA i ← 1 ATÉ 5 FAÇA
49INÍCIO
50PARA j ← 1 ATÉ 4 FAÇA
51INÍCIO
52ESCREVA “Elemento da posição “, i, “-”, j, “ = “, num[i][j]
53FIM
54FIM
55FIM_ALGORITMO.
Andrés
23 Feb 2019
1# cook your dish here
2tc = int(input())
3for _ in range(tc):
4    c = 0
5    n = int(input())
6    n = pow(2,n)
7    for x in range(0,n):
8        a = x ^ (x+1)
9        b = (x+2) ^ (x+3)
10        if(a==b):
11            c+=1
12    print(c)
Nele
13 Sep 2018
1''' Program for identify the Bulk density, Particle density, Percent pore space in python (pore space cylinder method)'''
2#Get the input via user interaction with the help of the variables w, v1, v1, v4
3w=input('Enter the weight of the soil taken in grams:')
4v1=input('Enter the volume of soil taken in ml:')
5v2=input('Enter the volume of water added in ml:')
6v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
7v3=float(v1)+float(v2)
8v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
9bd=float(w)/float(v1)
10pd=float(w)/(float(v1)-float(v5))
11pps=(float(v5)/float(v1))*100  #print the soil+water, pore space volume, bulk density, particle density, pore space
12print("volume of soil+water:",v3)
13print(" pore space volume:",v5)
14print("bulk density milligram per meter cube:",bd)
15print("particle density:",pd)
16print("percent pore space(in percentage):",pps)
17
Aria
14 Jun 2019
1importmath #Get the inputs via user interaction with help of variables Na ,Ca ,Mg
2Na=input ('Enter the value of Na+:')
3Ca=input ('Enter the value of Ca2:')
4Mg=input ('Enter the value of Mg2+:')#Calculation based on the formula
5sar=float(Na)/(math.sqrt((float(Ca)+float(Mg))/2))
6#Print the SAR
7print("SAR:",sar)#Control flow statement for remarks
8if sar>=0and sar<=10:
9print("water class=s1 Low sodium hazard Remarks: Little or no hazard")
10elif sar>=10and sar<=18:
11print("water class=s2 Medium sodium hazard  Remarks: Appreciable hazard but can be used with appropriate management techniques")
12elif sar>=18and sar<=26:
13print("water class=s3 high sodium hazard  Remarks: Unsatisfactory for most of the crops")
14elif sar>=26:
15print("water class=s4 very high sodium hazard  Remarks: Not suitable")
16
Kimmy
23 Jan 2018
1ALGORITMO
2DECLARE num[5,4] NUMÉRICO
3 num_aux, i, j, k, l, m, n, lin, col NUMÉRICO
4PARA i ← 1 ATÉ 5 FAÇA
5INÍCIO
6PARA j ← 1 ATÉ 4 FAÇA
7INÍCIO
8LEIA num_aux
9IF i = 1 E j = 1
10ENTÃO num[i, j] ← num_aux
11SENÃO INICIO
12 k ← 1
13 l ← 1
14 ENQUANTO num[k, l] < num_aux E (k  i OU l  j) FAÇA
15 INÍCIO
16 l ← l + 1
17 SE l > 4
18 ENTÃO INÍCIO
19 k ← k + 1
20 l ← 1
21 FIM
22 FIM
23 m ← i;
24 n ← j;
25 ENQUANTO m  k OU n  l FAÇA
26 INÍCIO
27 SE n-1 < 1 ENTÃO
28 INÍCIO
29 lin ← m-1
30 col ← 4
31 FIM
32 SENÃO INÍCIO
33 lin ← m
34 col ← n-1
35 FIM
36 num[m][n] ← num[lin][col]
37 n ← n-1
38 SE n < 1
39 ENTÃO INÍCIO
40 n ← 4
41 m ← m-1
42 FIM
43 FIM
44 num[k][l] ← num_aux
45 FIM
46FIM
47FIM
48PARA i ← 1 ATÉ 5 FAÇA
49INÍCIO
50PARA j ← 1 ATÉ 4 FAÇA
51INÍCIO
52ESCREVA “Elemento da posição “, i, “-”, j, “ = “, num[i][j]
53FIM
54FIM
55FIM_ALGORITMO.
56
Marta
06 Nov 2016
1# Raw Package
2import numpy as np
3import pandas as pd
4
5#Data Source
6import yfinance as yf
7
8#Data viz
9import plotly.graph_objs as go
10
11#Interval required 1 minute
12data = yf.download(tickers='UBER', period='1d', interval='1m')
13
14#declare figure
15fig = go.Figure()
16
17#Candlestick
18fig.add_trace(go.Candlestick(x=data.index,
19                open=data['Open'],
20                high=data['High'],
21                low=data['Low'],
22                close=data['Close'], name = 'market data'))
23
24# Add titles
25fig.update_layout(
26    title='Uber live share price evolution',
27    yaxis_title='Stock Price (USD per Shares)')
28
29# X-Axes
30fig.update_xaxes(
31    rangeslider_visible=True,
32    rangeselector=dict(
33        buttons=list([
34            dict(count=15, label="15m", step="minute", stepmode="backward"),
35            dict(count=45, label="45m", step="minute", stepmode="backward"),
36            dict(count=1, label="HTD", step="hour", stepmode="todate"),
37            dict(count=3, label="3h", step="hour", stepmode="backward"),
38            dict(step="all")
39        ])
40    )
41)
42
43#Show
44fig.show()
Mamadou
28 Oct 2016
1option=int(input('Press 1 for generating hamming code  \nPress 2 for finding error in hamming code\n\t Enter your choice:--\n'))
2
3if(option==1):  # GENERATE HAMMING CODE
4    print('Enter the data bits')
5    d=input()
6    data=list(d)
7    data.reverse()
8    c,ch,j,r,h=0,0,0,0,[]
9
10    while ((len(d)+r+1)>(pow(2,r))):
11        r=r+1
12
13    for i in range(0,(r+len(data))):
14        p=(2**c)
15
16        if(p==(i+1)):
17            h.append(0)
18            c=c+1
19
20        else:
21            h.append(int(data[j]))
22            j=j+1
23
24    for parity in range(0,(len(h))):
25        ph=(2**ch)
26        if(ph==(parity+1)):
27            startIndex=ph-1
28            i=startIndex
29            toXor=[]
30
31            while(i<len(h)):
32                block=h[i:i+ph]
33                toXor.extend(block)
34                i+=2*ph
35
36            for z in range(1,len(toXor)):
37                h[startIndex]=h[startIndex]^toXor[z]
38            ch+=1
39
40    h.reverse()
41    print('Hamming code generated would be:- ', end="")
42    print(int(''.join(map(str, h))))
43
44
45elif(option==2): # DETECT ERROR IN RECEIVED HAMMING CODE
46    print('Enter the hamming code received')
47    d=input()
48    data=list(d)
49    data.reverse()
50    c,ch,j,r,error,h,parity_list,h_copy=0,0,0,0,0,[],[],[]
51
52    for k in range(0,len(data)):
53        p=(2**c)
54        h.append(int(data[k]))
55        h_copy.append(data[k])
56        if(p==(k+1)):
57            c=c+1
58            
59    for parity in range(0,(len(h))):
60        ph=(2**ch)
61        if(ph==(parity+1)):
62
63            startIndex=ph-1
64            i=startIndex
65            toXor=[]
66
67            while(i<len(h)):
68                block=h[i:i+ph]
69                toXor.extend(block)
70                i+=2*ph
71
72            for z in range(1,len(toXor)):
73                h[startIndex]=h[startIndex]^toXor[z]
74            parity_list.append(h[parity])
75            ch+=1
76    parity_list.reverse()
77    error=sum(int(parity_list) * (2 ** i) for i, parity_list in enumerate(parity_list[::-1]))
78    
79    if((error)==0):
80        print('There is no error in the hamming code received')
81
82    elif((error)>=len(h_copy)):
83        print('Error cannot be detected')
84
85    else:
86        print('Error is in',error,'bit')
87
88        if(h_copy[error-1]=='0'):
89            h_copy[error-1]='1'
90
91        elif(h_copy[error-1]=='1'):
92            h_copy[error-1]='0'
93            print('After correction hamming code is:- ')
94        h_copy.reverse()
95        print(int(''.join(map(str, h_copy))))
96
97else:
98    print('Option entered does not exist')
Marie
27 Jul 2018
1x = 5
2y = 10
3print(x + y)
John
26 Jan 2020
1def main(str1, str2):
2    m = len(str1)
3    n = len(str2)
4    j = 0    
5    i = 0
6    while j < m and i < n:
7        if str1[j] == str2[i]:
8            j = j+1
9        i = i + 1
10    return j == m
11str2 = str(input())
12N = int(input())
13for i in range(N):
14    str1 = str(input())
15    if main(str1, str2):
16        print("POSITIVE") 
17    else:
18        print( "NEGATIVE")
Josie
12 Jan 2017
1#Get the input via user interaction with the help of the variables w, v1, v1, v4
2w=input('Enter the weight of the soil taken in grams:')
3v1=input('Enter the volume of soil taken in ml:')
4v2=input('Enter the volume of water added in ml:')
5v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
6v3=float(v1)+float(v2)
7v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
8bd=float(w)/float(v1)
9pd=float(w)/(float(v1)-float(v5))
10pps=(float(v5)/float(v1))*100  #print the soil+water, pore space volume, bulk density, particle density, pore space
11print("volume of soil+water:",v3)
12print(" pore space volume:",v5)
13print("bulk density milligram per meter cube:",bd)
14print("particle density:",pd)
15print("percent pore space(in percentage):",pps)
16