v1.1 if all algorithm are in one function, it will expand. so each operate type should be separated.

question: if add scientific

operation.cpp:

#include "operation.h"

int OperationAdd(string number1, string number2){

int result= atoi(number1.c_str())+atoi(number2.c_str());

return result;

}

int OperationMinus(string number1, string number2){

int result= atoi(number1.c_str())-atoi(number2.c_str());

return result;

}

int OperationBy(string number1, string number2){

int result= atoi(number1.c_str())*atoi(number2.c_str());

return result;

}

int OperationDivide(string number1, string number2){

int result= atoi(number1.c_str())/atoi(number2.c_str());

return result;

}

int Operation(string number1, string number2, string operateType){

int result=0;

if(operateType=="+"){

result = OperationAdd(number1, number2);

}

else if(operateType=="-"){

result = OperationMinus(number1, number2);

}

else if(operateType=="*"){

result = OperationBy(number1, number2);

}

else if(operateType=="/"){

result = OperationDivide(number1, number2);

}

else{

result =0;

}

return result;

}

to refactor for refactor的更多相关文章

  1. game to refactor for refactor

    first step, only aim to work. it works, but i have not seen the necessaty to use class yet. my quest ...

  2. Delphi Refactor 重构

    delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; ...

  3. [React] Refactor a Class Component with React hooks to a Function

    We have a render prop based class component that allows us to make a GraphQL request with a given qu ...

  4. Xcode的Refactor使用

    最近在看<重构>的书,想到Xcode有一个Refactor的功能,不知道您用的多不多,用这个功能在我们开发过程中,可以提高开发效率. Refactor 右键显示 Refactor 一.Re ...

  5. [Algorithms] Refactor a Linear Search into a Binary Search with JavaScript

    Binary search is an algorithm that accepts a sorted list and returns a search element from the list. ...

  6. [Algorithms] Refactor a Loop in JavaScript to Use Recursion

    Recursion is when a function calls itself. This self calling function handles at least two cases, th ...

  7. [React] Refactor a connected Redux component to use Unstated

    In this lesson, I refactor a simple Counter component connected to Redux to use Unstated instead. I ...

  8. [React] Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3

    The componentWillReceiveProps() method is being deprecated in future version of React (17). Many of ...

  9. [Ramda] Refactor to Point Free Functions with Ramda using compose and converge

    In this lesson we'll take some existing code and refactor it using some functions from the Ramda lib ...

随机推荐

  1. 【LeetCode每天一题】Divide Two Integers(两整数相除)

    Given two integers dividend and divisor, divide two integers without using multiplication, division ...

  2. js不能拦截302

    302跳转是浏览器自动处理并跳转 You can't handle redirects with XHR callbacks because the browser takes care of the ...

  3. 数据加密之MD5加密

    MD5是一个安全的散列算法,有两个特点:1.输入两个不同的明文(一段原始的数字信息)不会得到相同的输出值2.根据输出值,不能得到原始的明文,即过程不可逆所以要解密MD5没有现成的算法,只能用穷举法,把 ...

  4. OBV15 案例2

    BV

  5. sqli-labs(十八)

    第五十五关:和上一关类似,只是拼凑的方法不一样,所以需要先判断后台是怎么拼凑的 分别输入id=1'--+         id=1"--+             id=') --+     ...

  6. sqli-labs(十六)(order by注入)

    第四十六关: http://www.bubuko.com/infodetail-2481914.html 这有篇文章讲得还不错可以看下 这关是order by后面的一个注入,用报错注入和盲注都是可以的 ...

  7. Spark以yarn-client提交任务时报错超时,Connection to 192.168.. /has been quiet forms while there are outstanding requests. Failed to send RPC.....

    报错信息如上,具体是运行FusionInsight给的样例SparkPi,在local环境下是可以的,但是如果以yarn-client模式就会卡住,然后120s以后超时,其实以yarn-cluster ...

  8. jQuery获取点击对象的父级

    一.使用$('body').on('click','.index',function(event){})绑定事件时,例: <div class="project-box"&g ...

  9. python3 TypeError: a bytes-like object is required, not 'str'

    在学习<Python web开发学习实录>时, 例11-1: # !/usr/bin/env python # coding=utf-8 import socket sock = sock ...

  10. Java IO/NIO教程

    Java IO教程 http://tutorials.jenkov.com/java-io/index.html Java NIO教程 英文版: http://tutorials.jenkov.com ...