convert from python code to c++ code
import numpy as np from matplotlib import pylab as plt import math from collections import OrderedDict filename = 'comb.img' output = 'outputCV.img' output1 = 'BTimg.img' with open(filename , 'rb') as in_file: with open(output, 'wb') as out_file: out_file.write(in_file.read()[512:]) fo = open(output, 'rb') Output512 = np.fromfile(output, dtype='uint8', sep="") Output512 = Output512.reshape([512, 512]) with open(output , 'rb') as out_file1: myArr = bytearray(out_file1.read())
convert from python code to c++ code
def fibonacci (n): if n < 1: return [n] listSebelumN = fibonacci(n - 1) angka1 = listSebelumN[-2] if len(listSebelumN) > 2 else 0 angka2 = listSebelumN[-1] if len(listSebelumN) > 2 else 1 return listSebelumN + [angka1 + angka2] panjang = int(input('Masukkan panjang deret:')) # kita kurangin satu agar tidak kelebihan :D print(fibonacci(panjang - 1))
convert from python code to c++ code
n = input() if n == n[::-1]: print('Yes') elif n[-1] != '0': print('No') else: n = n.strip('0') if n == n[::-1]: print('Yes') else: print('No')
convert from python code to c++ code
n = int(input()) a = [] z = 0 for i in range(1, n + 1): a.append(input()) if i > 1: if a[i - 1] != a[i - 2]: z += 1 print(z + 1)
convert from python code to c++ code
print("The Magic Beanstalk\n") height = 100 hours = input("Enter a number of hours: ") string1 = "After 1 hour, the beanstalk was %d cm tall.", height print(string1) for i in hours: height = height*1.5 + 30 print("After %d hours, the beanstalk was %d cm tall. ", hours, height) print("And it's still growing!!!")
convert from python code to c++ code
test_case = int(input("Enter: ")) for _ in range(test_case): n,k = map(int,input().split()) ml= list(map(int,input().split())) ml.sort() sl= list(map(int,input().split())) sl.sort() sum_ml_sl = [] for i in range(min(n,10001)): nn = min(n,10001//(i+1)) for j in range(nn): sum_ml_sl.append(sl[i]+ml[j]) sum_ml_sl.sort() for i in range(k): q = int(input()) print(sum_ml_sl[q-1])