不知道在干嘛
虾鸡巴写一通
对不起
class Spreadsheet:
def __init__(self, rows: int):
self.data = [[0]*26 for _ in range(rows+1)]
def setCell(self, cell: str, value: int) -> None:
col = ord(cell[0])-ord('A')
row = int(cell[1:])
self.data[row][col] = value
def resetCell(self, cell: str) -> None:
col = ord(cell[0])-ord('A')
row = int(cell[1:])
self.data[row][col] = 0
def getValue(self, formula: str) -> int:
first = formula[1:].split('+')[0]
first_val = None
if ord('A') <= ord(first[0]) <= ord('Z'):
col = ord(first[0])-ord('A')
row = int(first[1:])
first_val = self.data[row][col]
else:
first_val = int(first)
second = formula[1:].split('+')[1]
second_val = None
if ord('A') <= ord(second[0]) <= ord('Z'):
col = ord(second[0])-ord('A')
row = int(second[1:])
second_val = self.data[row][col]
else:
second_val = int(second)
return first_val + second_val