""" class Matrice: def __init__(self,x,y): self.x = x self.y = y self.dct = {} #=dict() for i in range(y): for j in range(x): self.dct[ (i,j) ] = 0 def get(self,x,y): return self.dct[ (x,y) ] def set(self,x,y,val): self.dct[ (x,y) ] = val def afficher(self): for i in range(self.y): for j in range(self.x): print(self.dct[ (i,j) ]," ",end="") print() """ """ class Matrice: def __init__(self,x,y): self.x = x self.y = y self.lst = [0]*(x*y) def get(self,x,y): return self.lst[ y * self.x + x ] def set(self,x,y,val): self.lst[ y * self.x + x ] = val def afficher(self): for i in range(self.y): for j in range(self.x): print(self.lst[ i * self.x + j ]," ",end="") print() """ class Matrice: def __init__(self,x,y): self.x = x self.y = y self.lst = [] for i in range(y): self.lst.append( [0]*x ) def get(self,x,y): return self.lst[y][x] def set(self,x,y,val): self.lst[y][x] = val def afficher(self): for i in range(self.y): for j in range(self.x): print(self.lst[i][j]," ",end="") print() matrice = Matrice(5,5) matrice.afficher() matrice.set(1,1,5) print(matrice.get(1,1)) print(matrice.get(0,0)) matrice.afficher()