精華區beta Marginalman 關於我們 聯絡資訊
不知道在幹嘛 蝦雞巴寫一通 對不起 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 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.58.28 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1758298018.A.006.html
Smallsh: 大師 09/20 00:15