package com.homework5; public interface Compute { //声明抽象方法 int computer(int n,int m); } package com.homework5; public class jia implements Compute { @Override public int computer(int n, int m) { return n+m; } } package com.homework5; public class jia…
//接口Compute package jieKou; public interface Compute { int Computer(int n,int m); } //加 package jieKou; public class Jia implements Compute { @Override public int Computer(int n, int m) { // TODO 自动生成的方法存根 return m+n; } } //减 package jieKou; public c…
import res = '1-2*((60-30-(-40/5)*(9-2*5/3-7/3*99/4*2998-10*568/14.3))+(-4*3)/16-3)'s2 = 1-2*((60-30-(-40/5)*(9-2*5/3-7/3*99/4*2998-10*568/14.3))+(-4*3)/16-3)def check(s):#字符检错,不合法就返回False flag = True s = re.sub(' ','',s)#去空格 if re.findall('[^\d+\-*/…
1.极限压缩版 import re, functools def cal(formula): while re.search('(?:\d+\.?\d+|\d+)[+\-*/]', formula): while re.search('[*/]', formula): formula = re.sub('(?:\d+\.?\d+|\d+)[*/](?:\d+\.?\d+|\d+)', str(functools.reduce(lambda i, j: float(i) * float(j), r…