convertisseur code python en c code example
Example: 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( ))