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. 万恶之源 - Python模块一

    序列化 我们今天学习下序列化,什么是序列化呢? 将原本的字典.列表等内容转换成一个字符串的过程就叫做序列化. 为什么要有序列化模块: 比如,我们在python代码中计算的一个数据需要给另外一段程序使用 ...

  2. IOP知识点(2)

    1   URL资源访问不足时,需要添加URL权限 2   重定向问题解决办法:3  cloud-service-factory 项目 gradlew方法 1   URL资源访问不足时,需要添加URL权 ...

  3. Python 全栈开发八 文件处理

    一.基本流程 打开文件得到文件句柄 将文件句柄赋值给一个变量 通过文件句柄对文件进行操作 关闭文件 二.基本操作 1.文件句柄 f = open("a.txt",encoding= ...

  4. 2018-2019-1 20189221《Linux内核原理与分析》第一周作业

    Linux内核原理与分析 - 第一周作业 实验1 Linux系统简介 Linux历史 1991 年 10 月,Linus Torvalds想在自己的电脑上运行UNIX,可是 UNIX 的商业版本非常昂 ...

  5. VS Code的golang开发配置 之 代码提示

    之前用VS Code的时候,发现自己的代码的提示一直不好,换用JetBrain的Goland的代码提示是好了,但是比较占用资源.在网上找了一些资料,发现很多人也是遇到第三方或者自己的代码无法提示的情况 ...

  6. [文摘]那些一心想要离开 BAT 的人,后来怎么样了?

    人心是个无底洞,填不满也掏不空 <Working at Google seemed like a dream job. The reality has been a tedious, point ...

  7. 《算法笔记》8.1小节——搜索专题->深度优先搜索(DFS)

    http://codeup.cn/contest.php 5972 这是递归的入门题,求全排列,第一种方法用STL中的函数next_permutation,可以很容易的实现.首先建立好数组,将需要全排 ...

  8. js中两个!!的理解

    在js中经常有两个!!出现,经常让人难以理解 (function () { var a = 10; var b = 20; function add(num1, num2) { var num1 = ...

  9. iOS UI基础-9.1 UITableView 团购

    概述 接下来,我们要做的是团购界面的设计,最张要实现的效果图及项目结构图      团购数据的展示 思路: 系统自带的tableCell不能展示三个文本,不能满足条件,自定义tableCell 每一个 ...

  10. XML反序列化遇到数字型节点值为空导致反序列化异常

    实体类: [XmlRoot("stream")] public class _30320DuisiFukuanQueryResponseModel : ResponseModelB ...