给定两个正整数int a,int b,同时给定一个int type代表运算的类型,1为求a * b,0为求a / b,-1为求a - b,但规定只能使用加号,请编写程序返回计算结果,并保证数据合法且结果一定在int范围内。 测试样例: 1,2,1 返回:2
加载中...
import java.util.*; public class AddSubstitution { public int calc(int a, int b, int type) { // write code here } }
class AddSubstitution { public: int calc(int a, int b, int type) { // write code here } };
# -*- coding:utf-8 -*- class AddSubstitution: def calc(self, a, b, t): # write code here
class AddSubstitution { public int calc(int a, int b, int type) { // write code here } }