Konverter Python ke C online
console.log("Hello World!");
Good Grasshopper
console.log("Hello World!");
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int i,n,a=0,b=1,k;
cin>>n;
for(i=1;i<=n;i++)
{
k=b;
b=a+b;
a=k;
}
cout<<b;
}
def krushkal(connections):
from queue import PriorityQueue
from collections import defaultdict
def find(u): return root[u]
def union(u,v):
root[v] = u
children[u].append(v)
def reduceRank(u,v):
while children[v]:
child=children[v].pop()
root[child]=u
children[u].append(child)
E=len(connections)
children=defaultdict(list)
pq=PriorityQueue()#minHeap
vertices=set()#switches
for u,v,c in connections:
pq.put((c,u,v))
vertices.add(u)
vertices.add(v)
root = {v: v for v in vertices}
V = len(vertices)
ans=[]
minCost=0
e=0
while V-1!=e:#number of edges in resulting connections will v-1
c,u,v=pq.get()
r1=find(u)
r2=find(v)
if r1!=r2:
ans.append((u, v, c))
if r1!=u: u=r1
if r2!=v: v=r2
union(u,v)
e += 1
reduceRank(u,v)
minCost+=c
return ans,minCost
w1 = input('Enter the word to be replaced')
w2 = input('Enter the word which will replace w1')
n = int(input())
with open('fileee.txt','r') as file:
data = file.read()
if n<0:
data = data.replace(w1,w2)
elif n>len(data):
data = data.replace(w1,w2)
print(data.count(w2))
else:
data = data.replace(w1,w2,n)
with open('fileee.txt','w') as file:
file.write(data)